diff --git a/database/factories/EmployeeFactory.php b/database/factories/EmployeeFactory.php index 7fc9f23..9390d1c 100644 --- a/database/factories/EmployeeFactory.php +++ b/database/factories/EmployeeFactory.php @@ -20,12 +20,55 @@ public function definition(): array fake()->numerify('0812 #### #####'), ]), 'base_salary' => $this->faker->randomNumber(6), - 'gender' => $this->faker->randomElement(Gender::cases()), 'address' => $this->faker->address(), 'birthdate' => $this->faker->dateTimeBetween('-60 years', '-18 years')->format('Y-m-d'), 'hire_date' => $this->faker->date(), 'resign_date' => $this->faker->optional()->date(), - 'status' => $this->faker->randomElement(EmploymentStatus::cases()), ]; } + + public function male(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'gender' => Gender::MALE, + ]; + }); + } + + public function female(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'gender' => Gender::FEMALE, + ]; + }); + } + + public function permanent(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'status' => EmploymentStatus::PERMANENT, + ]; + }); + } + + public function contract(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'status' => EmploymentStatus::CONTRACT, + ]; + }); + } + + public function intern(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'status' => EmploymentStatus::INTERN, + ]; + }); + } } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 6ee2e98..d93b6a9 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -14,7 +14,24 @@ public function definition(): array 'email' => $this->faker->unique()->safeEmail(), 'username' => fake()->unique()->regexify('[A-Za-z0-9]{8}'), 'password' => Hash::make(config('myconfig.password_default')), - 'status' => $this->faker->randomElement(UserStatus::cases()), ]; } + + public function active(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'status' => UserStatus::ACTIVE, + ]; + }); + } + + public function inactive(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'status' => UserStatus::INACTIVE, + ]; + }); + } }