selected(); $holidays = $yearPeriod->holidays() ->get(); $vacations = $request->user() ->vacations() ->with("vacationRequest.vacations") ->whereBelongsTo($yearPeriod) ->approved() ->get(); $pendingVacations = $request->user() ->vacations() ->with("vacationRequest.vacations") ->whereBelongsTo($yearPeriod) ->pending() ->get(); return inertia("AnnualSummary", [ "holidays" => $holidays->mapWithKeys( fn(Holiday $holiday): array => [$holiday->date->toDateString() => $holiday->name], ), "vacations" => $vacations->mapWithKeys( fn(Vacation $vacation): array => [ $vacation->date->toDateString() => new SimpleVacationRequestResource($vacation->vacationRequest), ], ), "pendingVacations" => $pendingVacations->mapWithKeys( fn(Vacation $vacation): array => [ $vacation->date->toDateString() => new SimpleVacationRequestResource($vacation->vacationRequest), ], ), ]); } }