Refactor ShiftForm to streamline field definitions and implement unique code generation for shifts based on their names. Update ShiftFactory to utilize the new code generation method.
This commit is contained in:
@@ -27,14 +27,16 @@ class ShiftFactory extends Factory
|
||||
default => ['starts_at' => '22:00:00', 'ends_at' => '06:00:00'],
|
||||
};
|
||||
|
||||
$name = match ($code) {
|
||||
'A' => 'Morning Shift',
|
||||
'B' => 'Afternoon Shift',
|
||||
'C' => 'Evening Shift',
|
||||
default => 'Night Shift',
|
||||
};
|
||||
|
||||
return [
|
||||
'name' => match ($code) {
|
||||
'A' => 'Morning Shift',
|
||||
'B' => 'Afternoon Shift',
|
||||
'C' => 'Evening Shift',
|
||||
default => 'Night Shift',
|
||||
},
|
||||
'code' => $code.'-'.fake()->unique()->numerify('###'),
|
||||
'name' => $name,
|
||||
'code' => Shift::generateUniqueCodeFromName($name),
|
||||
'starts_at' => $times['starts_at'],
|
||||
'ends_at' => $times['ends_at'],
|
||||
'description' => fake()->optional()->sentence(),
|
||||
|
||||
Reference in New Issue
Block a user