<?php

namespace Database\Factories;

use App\Enums\EmploymentStatus;
use App\Models\Employee;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<Employee>
 */
class EmployeeFactory extends Factory
{
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'join_date' => fake()->dateTimeBetween('-5 years', 'now'),
            'resign_date' => null,
            'employment_status' => fake()->randomElement(EmploymentStatus::cases())->value,
            'base_salary' => fake()->numberBetween(2_000_000, 8_000_000),
        ];
    }

    public function resigned(): static
    {
        return $this->state(fn (array $attributes) => [
            'resign_date' => fake()->dateTimeBetween($attributes['join_date'] ?? '-1 year', 'now'),
        ]);
    }
}
