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

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

        $table->foreignId('document_type_id')
            ->constrained()
            ->restrictOnDelete();

        $table->string('document_number')->nullable();

        $table->date('issue_date')->nullable();
        $table->date('expiry_date')->nullable();

        $table->string('file_path');
        // storage path or reference (NOT binary)

        $table->boolean('verified')->default(false);
        $table->timestamp('verified_at')->nullable();
        $table->foreignId('verified_by')->nullable();
        // later → users table (HR verifier)

        $table->timestamps();

        // Prevent duplicate same document type per employee (optional)
        $table->unique(['employee_id', 'document_type_id']);
    });

    }

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