<?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('beneficiaries', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_employee_id');

            // Personal Information
            $table->string('first_name');
            $table->string('last_name');
            $table->text('address');
            $table->date('date_of_birth');

            // Allocation
            $table->decimal('percentage_allocation', 5, 2); // e.g., 100.00

            // File uploads (paths to stored files)
            $table->string('utility_bill_path')->nullable();
            $table->string('identification_path')->nullable();

            $table->timestamps();

            // Foreign key
            $table->foreign('company_employee_id')
                ->references('id')
                ->on('company_employees')
                ->onDelete('cascade');

            // Indexes
            $table->index('company_employee_id');
        });
    }

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