@@ -29,11 +29,11 @@ public function __construct()
2929 $ this ->dateFormatter = app (DateFormatter::class);
3030 }
3131
32- public function add (User $ employee , Location $ location , array $ data ): void
32+ public function add (User $ employee , array $ data ): void
3333 {
3434 Gate::forUser ($ employee )->authorize ('addAbsence ' , [
3535 Absence::class,
36- $ location
36+ $ employee -> currentLocation
3737 ]);
3838
3939 Validator::make ($ data , [
@@ -64,15 +64,15 @@ public function add(User $employee, Location $location, array $data): void
6464 $ calculator = new AbsenceCalculator (
6565 new EmployeeAbsenceCalendar (
6666 $ employee ,
67- $ location ,
67+ $ employee -> currentLocation ,
6868 new CarbonPeriod ($ startsAt , $ endsAt )
6969 ),
7070 AbsenceType::findOrFail ($ data ['absence_type_id ' ])
7171 );
7272
7373 $ absence = $ employee ->absences ()->create (
7474 [
75- 'location_id ' => $ location ->id ,
75+ 'location_id ' => $ employee -> currentLocation ->id ,
7676 'vacation_days ' => $ calculator ->sumVacationDays (),
7777 'paid_hours ' => $ calculator ->sumPaidHours (),
7878 'starts_at ' => $ startsAt ,
@@ -81,7 +81,7 @@ public function add(User $employee, Location $location, array $data): void
8181 );
8282
8383 $ admins = User::all ()->filter
84- ->hasLocationRole ($ location , 'admin ' );
84+ ->hasLocationRole ($ employee -> currentLocation , 'admin ' );
8585
8686 Mail::to ($ admins )
8787 ->send (new NewAbsenceWaitingForApproval ($ absence , $ employee ));
0 commit comments