<?php

namespace Database\Factories;

use App\Enums\EventType;
use App\Enums\GeneralType;
use App\Enums\TravelStatus;
use App\Models\ApprovalWorkflow;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TravelRequest>
 */
class TravelRequestFactory extends Factory
{
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'workflow_id' => null,
            'status' => TravelStatus::Draft,
            'reason_summary' => fake()->paragraph(),
            'event_type' => fake()->randomElement([null, EventType::Conference, EventType::AnnualInPersonMeeting]),
            'general_type' => null,
            'needs_accommodation' => fake()->boolean(),
            'needs_car_hire' => fake()->boolean(),
            'vehicle_policy_acknowledged' => false,
            'business_days' => fake()->numberBetween(1, 5),
            'private_days' => fake()->numberBetween(0, 3),
            'additional_notes' => fake()->optional()->sentence(),
            'submitted_at' => null,
        ];
    }

    public function pending(): static
    {
        return $this->state([
            'status' => TravelStatus::Pending,
            'submitted_at' => now(),
        ]);
    }

    public function approved(): static
    {
        return $this->state([
            'status' => TravelStatus::Approved,
            'submitted_at' => now(),
        ]);
    }

    public function rejected(): static
    {
        return $this->state([
            'status' => TravelStatus::Rejected,
            'submitted_at' => now(),
        ]);
    }
}
