diff --git a/app/Domain/DailySummaryRetriever.php b/app/Domain/DailySummaryRetriever.php index 5a495a22..2eaee6ae 100644 --- a/app/Domain/DailySummaryRetriever.php +++ b/app/Domain/DailySummaryRetriever.php @@ -59,7 +59,7 @@ public function getRemoteDays(Carbon $date): Collection public function getUpcomingAbsences(Carbon $date): Collection { return VacationRequest::query() - ->with(["user.profile", "vacations"]) + ->with(["user"]) ->whereDate("from", ">", $date) ->states(VacationRequestStatesRetriever::notFailedStates()) ->whereIn( diff --git a/app/Infrastructure/Http/Controllers/VacationRequestController.php b/app/Infrastructure/Http/Controllers/VacationRequestController.php index fa2fe44e..6bdb09e7 100644 --- a/app/Infrastructure/Http/Controllers/VacationRequestController.php +++ b/app/Infrastructure/Http/Controllers/VacationRequestController.php @@ -89,9 +89,7 @@ public function indexForApprovers( Request $request, YearPeriodRetriever $yearPeriodRetriever, ): RedirectResponse|Response { - $requestUser = $request->user(); - - if ($requestUser->cannot("listAllRequests")) { + if ($request->user()->cannot("listAllRequests")) { return redirect()->route("vacation.requests.index"); } @@ -101,11 +99,11 @@ public function indexForApprovers( $type = $request->get("type"); $vacationRequests = VacationRequest::query() - ->with(["user", "vacations.user.profile", "user.permissions", "user.profile"]) + ->with(["user", "vacations"]) ->whereBelongsTo($yearPeriod) ->when($user !== null, fn(Builder $query): Builder => $query->where("user_id", $user)) ->when($type !== null, fn(Builder $query): Builder => $query->where("type", $type)) - ->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $requestUser)) + ->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user())) ->latest() ->paginate(); diff --git a/app/Infrastructure/Http/Resources/VacationRequestResource.php b/app/Infrastructure/Http/Resources/VacationRequestResource.php index a5a785a3..e564ca56 100644 --- a/app/Infrastructure/Http/Resources/VacationRequestResource.php +++ b/app/Infrastructure/Http/Resources/VacationRequestResource.php @@ -38,7 +38,7 @@ public function toArray($request): array "to" => $this->to->toDisplayString(), "displayDate" => $this->getDate($this->from->toDisplayString(), $this->to->toDisplayString()), "comment" => $this->comment, - "days" => VacationResource::collection($this->vacations), + "days" => VacationResource::collection($this->vacations->load("user")), "can" => [ "acceptAsTechnical" => $this->resource->state->canTransitionTo(AcceptedByTechnical::class) && $user->can("acceptAsTechApprover", $this->resource), diff --git a/composer.json b/composer.json index 636e5635..14de3845 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "ext-pdo": "*", "ext-redis": "*", "azuyalabs/yasumi": "^2.6.0", + "barryvdh/laravel-debugbar": "^3.12", "barryvdh/laravel-dompdf": "^2.0.1", "doctrine/dbal": "^3.7.2", "fakerphp/faker": "^1.22.0",