<?php

namespace Database\Factories;

use App\Enums\ApprovalStatus;
use App\Models\ApprovalStep;
use App\Models\TravelRequest;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TravelRequestApproval>
 */
class TravelRequestApprovalFactory extends Factory
{
    public function definition(): array
    {
        return [
            'travel_request_id' => TravelRequest::factory(),
            'approval_step_id' => ApprovalStep::factory(),
            'approver_id' => null,
            'status' => ApprovalStatus::Pending,
            'comments' => null,
            'acted_at' => null,
        ];
    }

    public function approved(): static
    {
        return $this->state([
            'status' => ApprovalStatus::Approved,
            'approver_id' => User::factory(),
            'acted_at' => now(),
        ]);
    }

    public function rejected(): static
    {
        return $this->state([
            'status' => ApprovalStatus::Rejected,
            'approver_id' => User::factory(),
            'comments' => fake()->sentence(),
            'acted_at' => now(),
        ]);
    }
}
