Skip to content

Commit

Permalink
#513 - fix blocked user tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Baakoma committed Dec 17, 2024
1 parent a6960ea commit 72b8f7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/Http/Controllers/VacationRequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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,
],
Expand Down
9 changes: 9 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

Route::resource("users", UserController::class)
->except("show")
->withTrashed()
->whereNumber("user");
Route::get("/users/{user}", [UserController::class, "show"])
->withTrashed()
Expand All @@ -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)
Expand Down

0 comments on commit 72b8f7b

Please sign in to comment.