<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
       Schema::create('employee_exits', function (Blueprint $table) {
            $table->id();

            $table->foreignId('employee_id')
                ->constrained()
                ->cascadeOnDelete();

            $table->date('exit_date');

            $table->text('remarks')->nullable();

            // Flags (like your UI)
            $table->boolean('attendance')->default(true);
            $table->boolean('payroll')->default(true);
            $table->boolean('currently_working')->default(false);

            // Control
            $table->boolean('active')->default(true);

            $table->timestamps();

            $table->unique(['employee_id', 'exit_date']);
        });

    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('employee_exits');
    }
};
