<?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('attn_regularize', function (Blueprint $table) {
            $table->bigIncrements('ARG_Id');
            $table->string('ARG_Code', 10)->nullable();

            // ✅ FK - Employee
            $table->unsignedBigInteger('Emp_Id')->nullable();
            $table->foreign('Emp_Id')
                  ->references('Emp_Id')
                  ->on('employee_master')
                  ->onDelete('set null');

            $table->date('ARG_FDt');
            $table->date('ARG_TDt');

            $table->enum('ARG_Rsn', [
                'BIOMETRIC_FAILURE',
                'FORGOT_PUNCH',
                'FIELD_DUTY',
                'OFFICIAL_VISIT',
                'TOUR',
                'SYSTEM_ERROR',
                'OTHER'
            ]);

            $table->date('ARG_TIn');
            $table->date('ARG_TOu');

            $table->decimal('ARG_Days', 5, 2);

            $table->string('PlaceVisit', 50)->nullable();
            $table->decimal('HlDy_Btwn', 5, 2)->default(0);
            $table->string('Reason', 50)->nullable();

            // ✅ FK - Status
            $table->unsignedBigInteger('Status')->nullable();
            $table->foreign('Status')
                  ->references('Act_Id')
                  ->on('action_master')
                  ->onDelete('set null');

            $table->timestamps();
            $table->softDeletes();
        });
    }

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