selected(); $startDate = Carbon::createFromDate($yearPeriod->year)->startOfYear()->startOfWeek(); $endDate = Carbon::createFromDate($yearPeriod->year)->endOfYear()->endOfWeek(); $holidays = $yearPeriod->holidays() ->whereBetween("date", [$startDate, $endDate]) ->get(); $vacations = $request->user() ->vacations() ->with("vacationRequest.vacations") ->whereBetween("date", [$startDate, $endDate]) ->approved() ->get(); $pendingVacations = $request->user() ->vacations() ->with("vacationRequest.vacations") ->whereBetween("date", [$startDate, $endDate]) ->pending() ->get(); return inertia("AnnualSummary", [ "holidays" => $holidays->mapWithKeys(fn(Holiday $holiday) => [$holiday->date->toDateString() => $holiday->name]), "vacations" => $vacations->mapWithKeys(fn(Vacation $vacation) => [$vacation->date->toDateString() => new SimpleVacationRequestResource($vacation->vacationRequest)]), "pendingVacations" => $pendingVacations->mapWithKeys(fn(Vacation $vacation) => [$vacation->date->toDateString() => new SimpleVacationRequestResource($vacation->vacationRequest)]), ]); } }