<?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()
{
    Schema::create('attn_regularize', function (Blueprint $table) {
        $table->bigIncrements('ARG_id');

        $table->string('ARG_Code', 10)->nullable();

        $table->unsignedBigInteger('Emp_Id')->nullable();

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

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

        $table->dateTime('ARG_TIn')->nullable();
        $table->dateTime('ARG_TOu')->nullable();

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

        $table->string('PlaceVisit', 50)->nullable();

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

        // ✅ HOD fields
        $table->unsignedBigInteger('ARG_HOD')->nullable();
        $table->timestamp('ARG_HDT')->nullable();

        $table->string('Reason', 50)->nullable();

        $table->unsignedBigInteger('Status')->nullable();

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

        // ✅ Foreign Keys
        $table->foreign('Emp_Id')->references('Emp_Id')->on('employee_master')->nullOnDelete();
        $table->foreign('ARG_HOD')->references('Usr_Id')->on('user_master')->nullOnDelete();
        $table->foreign('Status')->references('Act_Id')->on('action_master')->nullOnDelete();
    });
}

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