This commit is contained in:
Adrian Hopek
2022-01-24 10:23:08 +01:00
parent 75889a16e6
commit 62fc1e1ca9
14 changed files with 51 additions and 37 deletions

View File

@@ -14,8 +14,9 @@ use Toby\Models\YearPeriod;
class DatabaseSeeder extends Seeder
{
public function __construct(protected UserAvatarGenerator $avatarGenerator)
{
public function __construct(
protected UserAvatarGenerator $avatarGenerator,
) {
}
public function run(): void
@@ -23,7 +24,7 @@ class DatabaseSeeder extends Seeder
User::unsetEventDispatcher();
YearPeriod::unsetEventDispatcher();
User::factory(14)->create();
User::factory(9)->create();
User::factory([
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
])->create();
@@ -35,11 +36,17 @@ class DatabaseSeeder extends Seeder
YearPeriod::factory()
->count(3)
->sequence(
["year" => Carbon::now()->year - 1],
["year" => Carbon::now()->year],
["year" => Carbon::now()->year + 1],
[
"year" => Carbon::now()->year - 1,
],
[
"year" => Carbon::now()->year,
],
[
"year" => Carbon::now()->year + 1,
],
)
->afterCreating(function (YearPeriod $yearPeriod) use ($users) {
->afterCreating(function (YearPeriod $yearPeriod) use ($users): void {
foreach ($users as $user) {
VacationLimit::factory()
->for($yearPeriod)
@@ -47,7 +54,7 @@ class DatabaseSeeder extends Seeder
->create();
}
})
->create();
->create();
}
protected function generateAvatarsForUsers(Collection $users): void