<?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('travel_requests', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->foreignId('workflow_id')->nullable()->constrained('approval_workflows')->nullOnDelete();
            $table->string('status')->default('Draft');
            $table->text('reason_summary');
            $table->string('event_type')->nullable();
            $table->string('general_type')->nullable();
            $table->boolean('needs_accommodation')->default(false);
            $table->boolean('needs_car_hire')->default(false);
            $table->boolean('vehicle_policy_acknowledged')->default(false);
            $table->unsignedInteger('business_days')->default(0);
            $table->unsignedInteger('private_days')->default(0);
            $table->text('additional_notes')->nullable();
            $table->timestamp('submitted_at')->nullable();
            $table->timestamps();
        });
    }

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