Last active
January 29, 2026 05:00
-
-
Save kidino/a42476a77245da28d04d527bb3c4c6e2 to your computer and use it in GitHub Desktop.
leave factory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Database\Factories; | |
| use Illuminate\Database\Eloquent\Factories\Factory; | |
| /** | |
| * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\LeaveApplication> | |
| */ | |
| class LeaveApplicationFactory extends Factory | |
| { | |
| /** | |
| * Define the model's default state. | |
| * | |
| * @return array<string, mixed> | |
| */ | |
| public function definition(): array | |
| { | |
| $fromDate = fake()->dateTimeBetween('-30 days', '+30 days'); | |
| $toDate = fake()->dateTimeBetween($fromDate->format('Y-m-d'), | |
| $fromDate->format('Y-m-d') . ' +14 days'); | |
| return [ | |
| 'user_id' => \App\Models\User::inRandomOrder()->first()?->id ?? | |
| \App\Models\User::factory(), | |
| 'from_date' => $fromDate, | |
| 'to_date' => $toDate, | |
| 'leave_type' => fake()->randomElement(['annual','medical','compassionate','emergency']), | |
| 'status' => fake()->randomElement(['pending','approved','rejected','revoked']), | |
| ]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment