This commit is contained in:
Adrian Hopek
2022-01-21 08:45:42 +01:00
parent 652587dbf1
commit a62a428781
12 changed files with 420 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Carbon;
use Toby\Models\User;
use Toby\Models\VacationLimit;
use Toby\Models\YearPeriod;
class DatabaseSeeder extends Seeder
@@ -18,11 +19,23 @@ class DatabaseSeeder extends Seeder
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
])->create();
YearPeriod::factory([
"year" => Carbon::now()->year,
])->create();
YearPeriod::factory([
"year" => Carbon::now()->year + 1,
])->create();
$users = User::all();
YearPeriod::factory()
->count(3)
->sequence(
["year" => Carbon::now()->year - 1],
["year" => Carbon::now()->year],
["year" => Carbon::now()->year + 1],
)
->afterCreating(function (YearPeriod $yearPeriod) use ($users) {
foreach ($users as $user) {
VacationLimit::factory()
->for($yearPeriod)
->for($user)
->create();
}
})
->create();
}
}