<?php

namespace Database\Factories;

use App\Domain\HR\Enums\EmployeeStatus;
use App\Domain\Organization\Models\Company;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class EmployeeFactory extends Factory
{
    public function definition(): array
    {
        return [
            'employee_code' => 'EMP-TST-'.Str::padLeft((string) $this->faker->unique()->numberBetween(1, 999999), 6, '0'),
            'company_id' => Company::factory(),
            'full_name' => $this->faker->name(),
            'designation' => $this->faker->jobTitle(),
            'mobile' => $this->faker->numerify('01#########'),
            'email' => $this->faker->unique()->safeEmail(),
            'employment_type' => 'full_time',
            'status' => EmployeeStatus::Active->value,
            'joining_date' => $this->faker->dateTimeBetween('-5 years')->format('Y-m-d'),
        ];
    }

    public function status(EmployeeStatus $status): static
    {
        return $this->state(fn () => ['status' => $status->value]);
    }
}
