diff --git a/app/Http/Controllers/VacationRequestController.php b/app/Http/Controllers/VacationRequestController.php index 832b3390..b77f9e01 100644 --- a/app/Http/Controllers/VacationRequestController.php +++ b/app/Http/Controllers/VacationRequestController.php @@ -104,15 +104,19 @@ public function indexForApprovers( $year = $request->get("year"); $status = $request->get("status", "all"); - $user = $request->get("user"); $type = $request->get("type"); $authUser = $request->user(); $withTrashedUsers = $authUser->canSeeInactiveUsers(); + $user = User::query() + ->withTrashed($withTrashedUsers) + ->where("id", $request->get("user")) + ->first(); + $vacationRequests = VacationRequest::query() ->with(["vacations.user.profile", "user.permissions", "user.profile"]) ->whereRelation("user", fn(Builder $query): Builder => $query->withTrashed($withTrashedUsers)) - ->when($user !== null, fn(Builder $query): Builder => $query->where("user_id", $user)) + ->when($user !== null, fn(Builder $query): Builder => $query->whereBelongsTo($user)) ->when($type !== null, fn(Builder $query): Builder => $query->where("type", $type)) ->when($year !== null, fn(Builder $query): Builder => $query->whereYear("from", $year)) ->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $authUser)) @@ -131,7 +135,7 @@ public function indexForApprovers( "types" => VacationType::casesToSelect(), "filters" => [ "status" => $status, - "user" => (int)$user, + "user" => $user?->id, "type" => $type, "year" => $year === null ? $year : (int)$year, ], diff --git a/routes/web.php b/routes/web.php index 38ad0bd4..d39b861d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -39,6 +39,7 @@ Route::resource("users", UserController::class) ->except("show") + ->withTrashed() ->whereNumber("user"); Route::get("/users/{user}", [UserController::class, "show"]) ->withTrashed() @@ -47,21 +48,29 @@ ->whereNumber("user") ->withTrashed(); Route::get("/users/{user}/permissions", [PermissionController::class, "show"]) + ->withTrashed() ->whereNumber("user"); Route::patch("/users/{user}/permissions", [PermissionController::class, "update"]) + ->withTrashed() ->whereNumber("user"); Route::get("/users/{user}/history", [UserHistoryController::class, "index"]) + ->withTrashed() ->whereNumber("user") ->name("users.history"); Route::get("/users/{user}/history/create", [UserHistoryController::class, "create"]) + ->withTrashed() ->whereNumber("user"); Route::post("/users/{user}/history", [UserHistoryController::class, "store"]) + ->withTrashed() ->whereNumber("user"); Route::get("/users/history/{history}", [UserHistoryController::class, "edit"]) + ->withTrashed() ->whereNumber("history"); Route::put("/users/history/{history}", [UserHistoryController::class, "update"]) + ->withTrashed() ->whereNumber("history"); Route::delete("/users/history/{history}", [UserHistoryController::class, "destroy"]) + ->withTrashed() ->whereNumber("history"); Route::resource("equipment-items", EquipmentController::class)