This commit is contained in:
Adrian Hopek 2022-03-16 14:32:33 +01:00
parent d1bef0ac92
commit 0e482f84fc

View File

@ -33,19 +33,19 @@ class DemoSeeder extends Seeder
YearPeriod::unsetEventDispatcher(); YearPeriod::unsetEventDispatcher();
VacationRequest::unsetEventDispatcher(); VacationRequest::unsetEventDispatcher();
$employee1 = User::factory([ $user = User::factory([
"first_name" => "Jan", "first_name" => "Jan",
"last_name" => "Kowalski", "last_name" => "Kowalski",
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"), "email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
"employment_form" => EmploymentForm::EmploymentContract, "employment_form" => EmploymentForm::EmploymentContract,
"position" => "programista", "position" => "programista",
"role" => Role::Employee, "role" => Role::Administrator,
"employment_date" => Carbon::createFromDate(2021, 12, 31), "employment_date" => Carbon::createFromDate(2021, 12, 31),
"remember_token" => Str::random(10), "remember_token" => Str::random(10),
]) ])
->create(); ->create();
$employee2 = User::factory([ User::factory([
"first_name" => "Anna", "first_name" => "Anna",
"last_name" => "Nowak", "last_name" => "Nowak",
"email" => "anna.nowak@example.com", "email" => "anna.nowak@example.com",
@ -57,7 +57,7 @@ class DemoSeeder extends Seeder
]) ])
->create(); ->create();
$employee3 = User::factory([ User::factory([
"first_name" => "Tola", "first_name" => "Tola",
"last_name" => "Sawicka", "last_name" => "Sawicka",
"email" => "tola.sawicka@example.com", "email" => "tola.sawicka@example.com",
@ -93,7 +93,7 @@ class DemoSeeder extends Seeder
]) ])
->create(); ->create();
$admin = User::factory([ User::factory([
"first_name" => "Miłosz", "first_name" => "Miłosz",
"last_name" => "Borowski", "last_name" => "Borowski",
"email" => "milosz.borowski@example.com", "email" => "milosz.borowski@example.com",
@ -151,8 +151,8 @@ class DemoSeeder extends Seeder
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Komentarz do wniosku urlopowego.", "comment" => "Komentarz do wniosku urlopowego.",
]) ])
->for($employee1) ->for($user)
->for($employee1, "creator") ->for($user, "creator")
->for($currentYearPeriod) ->for($currentYearPeriod)
->afterCreating(function (VacationRequest $vacationRequest): void { ->afterCreating(function (VacationRequest $vacationRequest): void {
$days = app(VacationDaysCalculator::class)->calculateDays( $days = app(VacationDaysCalculator::class)->calculateDays(
@ -175,7 +175,7 @@ class DemoSeeder extends Seeder
"from" => null, "from" => null,
"to" => Created::class, "to" => Created::class,
])->for($vacationRequestApproved) ])->for($vacationRequestApproved)
->for($employee1) ->for($user)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
@ -221,8 +221,8 @@ class DemoSeeder extends Seeder
"to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(),
"comment" => "Komentarz do wniosku urlopowego.", "comment" => "Komentarz do wniosku urlopowego.",
]) ])
->for($employee1) ->for($user)
->for($employee1, "creator") ->for($user, "creator")
->for($currentYearPeriod) ->for($currentYearPeriod)
->afterCreating(function (VacationRequest $vacationRequest): void { ->afterCreating(function (VacationRequest $vacationRequest): void {
$days = app(VacationDaysCalculator::class)->calculateDays( $days = app(VacationDaysCalculator::class)->calculateDays(
@ -245,7 +245,7 @@ class DemoSeeder extends Seeder
"from" => null, "from" => null,
"to" => Created::class, "to" => Created::class,
])->for($vacationRequestWaitsForAdminApproval) ])->for($vacationRequestWaitsForAdminApproval)
->for($employee1) ->for($user)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([
@ -278,8 +278,8 @@ class DemoSeeder extends Seeder
"to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"comment" => "", "comment" => "",
]) ])
->for($employee1) ->for($user)
->for($employee1, "creator") ->for($user, "creator")
->for($currentYearPeriod) ->for($currentYearPeriod)
->afterCreating(function (VacationRequest $vacationRequest): void { ->afterCreating(function (VacationRequest $vacationRequest): void {
$days = app(VacationDaysCalculator::class)->calculateDays( $days = app(VacationDaysCalculator::class)->calculateDays(
@ -302,7 +302,7 @@ class DemoSeeder extends Seeder
"from" => null, "from" => null,
"to" => Created::class, "to" => Created::class,
])->for($vacationRequestRejected) ])->for($vacationRequestRejected)
->for($employee1) ->for($user)
->create(); ->create();
VacationRequestActivity::factory([ VacationRequestActivity::factory([