<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('employee_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('employee_id')->constrained('employees')->onDelete('cascade');
            $table->foreignId('company_id')->constrained('companies')->onDelete('cascade');
            $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
            $table->enum('log_type', [
                'salary_increase', 'salary_decrease', 'promotion', 'demotion',
                'sick_leave', 'annual_leave', 'maternity_leave', 'paternity_leave',
                'unpaid_leave', 'bonus', 'disciplinary_action', 'termination',
                'hire', 'transfer', 'training', 'performance_review', 'other'
            ])->default('other');
            $table->decimal('amount_change', 15, 2)->nullable();
            $table->date('effective_date');
            $table->date('end_date')->nullable();
            $table->text('description')->nullable();
            $table->text('notes')->nullable();
            $table->string('attachment_path')->nullable();
            $table->enum('status', ['active', 'reversed', 'pending', 'completed'])->default('completed');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('employee_logs');
    }
};
