authorize("generateTimesheet"); $yearPeriod = $yearPeriodRetriever->selected(); $carbonMonth = Carbon::create($yearPeriod->year, $month->toCarbonNumber()); $users = User::query() ->whereRelation("profile", "employment_form", EmploymentForm::EmploymentContract) ->orderByProfileField("last_name") ->orderByProfileField("first_name") ->get(); $types = VacationType::all() ->filter( fn(VacationType $type) => $configRetriever->isAvailableFor($type, EmploymentForm::EmploymentContract), ); $filename = "{$carbonMonth->translatedFormat("F Y")}.xlsx"; $timesheet = (new TimesheetExport()) ->forMonth($carbonMonth) ->forUsers($users) ->forVacationTypes($types); return Excel::download($timesheet, $filename); } }