<?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('emp_attendance', function (Blueprint $table) {
            $table->bigIncrements('EA_id');
            $table->string('EA_Code', 10)->nullable();

            $table->date('EA_Date');

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

            $table->integer('EA_Month')->nullable();
            $table->year('Fr_Year');

            $table->text('Attn_Text');
            $table->decimal('Total_Text', 10, 2)->nullable();

            $table->unsignedBigInteger('Status')->default(1);

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

            // 🔗 Foreign Keys
            $table->foreign('PRB_id')->references('PRB_id')->on('payroll_bills')->nullOnDelete();
            $table->foreign('Emp_Id')->references('Emp_Id')->on('employee_master')->cascadeOnDelete();
            $table->foreign('Status')->references('Act_Id')->on('action_master');
        });
    }

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