refactor(factory): membuat state
This commit is contained in:
parent
ebf6cd78ea
commit
8d70869766
@ -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,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user