<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLeaveApplicationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('leave_applications', function (Blueprint $table) {
            $table->id();

            // Service Member Information
            $table->string('full_name');
            $table->string('service_number');
            $table->string('rank');
            $table->string('service_status');
            $table->string('country');

            // Applicant Information
            $table->string('applicant_name');
            $table->string('relationship');

            // Leave Details
            $table->string('leave_type');
            $table->integer('leave_balance')->nullable();
            $table->date('start_date');
            $table->date('end_date');
            $table->integer('days_requested');

            // Contact Information
            $table->string('applicant_phone');
            $table->string('applicant_email');
            $table->text('leave_address');

            // Justification
            $table->text('justification');

            // Status and metadata
            $table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
            $table->timestamp('submitted_at')->useCurrent();
            $table->timestamps();
        });
    }

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