create(); User::factory([ "email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"), ])->create(); $users = User::all(); $this->generateAvatarsForUsers($users); 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): void { foreach ($users as $user) { VacationLimit::factory() ->for($yearPeriod) ->for($user) ->create(); } }) ->afterCreating(function (YearPeriod $yearPeriod): void { $polishHolidaysRetriever = new PolishHolidaysRetriever(); foreach ($polishHolidaysRetriever->getForYearPeriod($yearPeriod) as $holiday) { $yearPeriod->holidays()->create([ "name" => $holiday["name"], "date" => $holiday["date"], ]); } }) ->create(); } protected function generateAvatarsForUsers(Collection $users): void { foreach ($users as $user) { $user->saveAvatar($this->avatarGenerator->generateFor($user)); } } }