*/ class EmployeeFactory extends Factory { protected $model = Employee::class; /** * @return array */ public function definition(): array { $hireDate = fake()->dateTimeBetween('-10 years', '-1 month'); $birthDate = fake()->dateTimeBetween('-55 years', '-20 years'); $employmentStatus = fake()->randomElement(EmploymentStatus::cases()); $gender = fake()->randomElement(Gender::cases()); return [ 'employee_number' => 'EMP-'.fake()->unique()->numerify('#####'), 'full_name' => fake()->name($gender === Gender::Female ? 'female' : 'male'), 'national_id' => fake()->optional(0.8)->numerify('##########'), 'gender' => $gender, 'birth_date' => $birthDate, 'phone' => '+993 61 92 92 48', 'address' => fake()->optional()->address(), 'department_id' => Department::factory(), 'position_id' => Position::factory(), 'shift_id' => Shift::factory(), 'employment_status' => $employmentStatus, 'hire_date' => $hireDate, 'termination_date' => $employmentStatus === EmploymentStatus::Terminated ? fake()->dateTimeBetween($hireDate, 'now') : null, 'notes' => fake()->optional(0.3)->sentence(), 'profile_photo_path' => null, ]; } public function active(): static { return $this->state(fn (array $attributes): array => [ 'employment_status' => EmploymentStatus::Active, 'termination_date' => null, ]); } public function terminated(): static { return $this->state(function (array $attributes): array { $hireDate = $attributes['hire_date'] ?? fake()->dateTimeBetween('-5 years', '-1 year'); return [ 'employment_status' => EmploymentStatus::Terminated, 'termination_date' => fake()->dateTimeBetween($hireDate, 'now'), ]; }); } }