Skip to content

Commit

Permalink
Merge branch 'main' into #398-tidy-up-queries
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/Domain/DailySummaryRetriever.php
#	app/Domain/DashboardAggregator.php
#	app/Infrastructure/Http/Controllers/VacationRequestController.php
#	composer.lock
  • Loading branch information
kamilpiech97 committed Mar 20, 2024
2 parents d689b60 + c96aa4e commit 8f500dc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Domain/DailySummaryRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8f500dc

Please sign in to comment.