<?php

namespace Database\Factories;

use App\Models\EmployeeAdvance;
use App\Models\LeaveRequest;
use App\Models\Rejection;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<Rejection>
 */
class RejectionFactory extends Factory
{
    public function definition(): array
    {
        return [
            'rejectable_type' => EmployeeAdvance::class,
            'rejectable_id' => EmployeeAdvance::factory(),
            'reason' => fake()->sentence(),
            'rejected_by_id' => User::factory(),
        ];
    }

    public function forLeaveRequest(): static
    {
        return $this->state(fn (array $attributes) => [
            'rejectable_type' => LeaveRequest::class,
            'rejectable_id' => LeaveRequest::factory()->state([
                'status' => 'rejected',
            ]),
        ]);
    }
}
