diff --git a/app/Architecture/Providers/AppServiceProvider.php b/app/Architecture/Providers/AppServiceProvider.php index e8fc76c0..137bdd52 100644 --- a/app/Architecture/Providers/AppServiceProvider.php +++ b/app/Architecture/Providers/AppServiceProvider.php @@ -5,6 +5,7 @@ namespace Toby\Architecture\Providers; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\ChannelManager; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Notification; @@ -22,6 +23,7 @@ public function register(): void public function boot(): void { + Model::preventLazyLoading(!app()->isProduction()); Carbon::macro("toDisplayString", fn(): string => $this->translatedFormat("d.m.Y")); Carbon::macro("toDisplayDateTimeString", fn(): string => $this->translatedFormat("d.m.Y H:i:s")); } diff --git a/app/Domain/Actions/VacationRequest/WaitForTechApprovalAction.php b/app/Domain/Actions/VacationRequest/WaitForTechApprovalAction.php index 01c08877..6b8bd417 100644 --- a/app/Domain/Actions/VacationRequest/WaitForTechApprovalAction.php +++ b/app/Domain/Actions/VacationRequest/WaitForTechApprovalAction.php @@ -35,6 +35,7 @@ protected function notifyTechApprovers(VacationRequest $vacationRequest): void { $users = Permission::findByName("receiveVacationRequestWaitsForApprovalNotification") ->users() + ->with("permissions") ->get(); $users = $users->filter(fn(User $user): bool => $user->can("acceptAsTechApprover", $vacationRequest)); diff --git a/app/Domain/CalendarGenerator.php b/app/Domain/CalendarGenerator.php index fb11327c..86c1f4b5 100644 --- a/app/Domain/CalendarGenerator.php +++ b/app/Domain/CalendarGenerator.php @@ -59,7 +59,7 @@ protected function getVacationsForPeriod(CarbonPeriod $period): Collection ->orWhere(function ($query): void { $query->pending(); }) - ->with("vacationRequest") + ->with("vacationRequest.vacations") ->get() ->groupBy(fn(Vacation $vacation): string => $vacation->date->toDateString()); } diff --git a/app/Domain/DailySummaryRetriever.php b/app/Domain/DailySummaryRetriever.php index c6a355c6..d5f6b024 100644 --- a/app/Domain/DailySummaryRetriever.php +++ b/app/Domain/DailySummaryRetriever.php @@ -23,7 +23,7 @@ public function __construct( public function getAbsences(Carbon $date): Collection { return VacationRequest::query() - ->with(["user"]) + ->with(["user", "vacations"]) ->whereDate("from", "<=", $date) ->whereDate("to", ">=", $date) ->states(VacationRequestStatesRetriever::notFailedStates()) @@ -41,7 +41,7 @@ public function getAbsences(Carbon $date): Collection public function getRemoteDays(Carbon $date): Collection { return VacationRequest::query() - ->with(["user"]) + ->with(["user", "vacations"]) ->whereDate("from", "<=", $date) ->whereDate("to", ">=", $date) ->states(VacationRequestStatesRetriever::notFailedStates()) @@ -59,7 +59,7 @@ public function getRemoteDays(Carbon $date): Collection public function getUpcomingAbsences(Carbon $date): Collection { return VacationRequest::query() - ->with(["user"]) + ->with(["user", "vacations"]) ->whereDate("from", ">", $date) ->states(VacationRequestStatesRetriever::notFailedStates()) ->whereIn( @@ -77,7 +77,7 @@ public function getUpcomingAbsences(Carbon $date): Collection public function getUpcomingRemoteDays(Carbon $date): Collection { return VacationRequest::query() - ->with(["user"]) + ->with(["user", "vacations"]) ->whereDate("from", ">", $date) ->states(VacationRequestStatesRetriever::notFailedStates()) ->whereIn( diff --git a/app/Domain/DashboardAggregator.php b/app/Domain/DashboardAggregator.php index 34ca22ba..b3c3e595 100644 --- a/app/Domain/DashboardAggregator.php +++ b/app/Domain/DashboardAggregator.php @@ -55,7 +55,7 @@ public function aggregateCalendarData(User $user, YearPeriod $yearPeriod): array ->get() ->mapWithKeys( fn(Vacation $vacation): array => [ - $vacation->date->toDateString() => new DashboardVacationRequestResource($vacation->vacationRequest), + $vacation->date->toDateString() => new DashboardVacationRequestResource($vacation->vacationRequest->load(["user", "vacations"])), ], ); @@ -67,7 +67,7 @@ public function aggregateCalendarData(User $user, YearPeriod $yearPeriod): array ->get() ->mapWithKeys( fn(Vacation $vacation): array => [ - $vacation->date->toDateString() => new DashboardVacationRequestResource($vacation->vacationRequest), + $vacation->date->toDateString() => new DashboardVacationRequestResource($vacation->vacationRequest->load(["user", "vacations"])), ], ); @@ -86,14 +86,14 @@ public function aggregateVacationRequests(User $user, YearPeriod $yearPeriod): J { if ($user->can("listAllRequests")) { $vacationRequests = $yearPeriod->vacationRequests() - ->with(["user"]) + ->with(["user", "vacations"]) ->states(VacationRequestStatesRetriever::waitingForUserActionStates($user)) ->latest("updated_at") ->limit(3) ->get(); } else { $vacationRequests = $user->vacationRequests() - ->with(["user"]) + ->with(["user", "vacations"]) ->whereBelongsTo($yearPeriod) ->latest("updated_at") ->limit(3) diff --git a/app/Infrastructure/Http/Controllers/EquipmentController.php b/app/Infrastructure/Http/Controllers/EquipmentController.php index 9487b4fe..c793f563 100644 --- a/app/Infrastructure/Http/Controllers/EquipmentController.php +++ b/app/Infrastructure/Http/Controllers/EquipmentController.php @@ -33,6 +33,7 @@ public function index(Request $request): RedirectResponse|Response $searchQuery = $request->query("search"); $equipmentItems = EquipmentItem::query() + ->with("assignee") ->search($searchQuery) ->when( $request->query("assignee") && $request->query("assignee") !== "unassigned", @@ -72,6 +73,7 @@ public function indexForEmployee(Request $request): RedirectResponse|Response $searchQuery = $request->query("search"); $equipmentItems = EquipmentItem::query() + ->with("assignee") ->search($searchQuery) ->labels($request->query("labels")) ->where("assignee_id", $request->user()->id) @@ -172,7 +174,7 @@ public function downloadExcel(): BinaryFileResponse { $this->authorize("manageEquipment"); - $equipmentItems = EquipmentItem::query()->get(); + $equipmentItems = EquipmentItem::query()->with("assignee")->get(); $equipmentExport = new EquipmentExport($equipmentItems); diff --git a/app/Infrastructure/Http/Controllers/KeysController.php b/app/Infrastructure/Http/Controllers/KeysController.php index e6377ceb..f62071b4 100644 --- a/app/Infrastructure/Http/Controllers/KeysController.php +++ b/app/Infrastructure/Http/Controllers/KeysController.php @@ -23,6 +23,7 @@ class KeysController extends Controller public function index(Request $request): Response { $keys = Key::query() + ->with("user") ->get() ->sortBy("id"); diff --git a/app/Infrastructure/Http/Controllers/ResumeController.php b/app/Infrastructure/Http/Controllers/ResumeController.php index fa50f131..bf0167a6 100644 --- a/app/Infrastructure/Http/Controllers/ResumeController.php +++ b/app/Infrastructure/Http/Controllers/ResumeController.php @@ -23,6 +23,7 @@ public function index(): Response $this->authorize("manageResumes"); $resumes = Resume::query() + ->with("user") ->latest("updated_at") ->paginate(); diff --git a/app/Infrastructure/Http/Controllers/VacationRequestController.php b/app/Infrastructure/Http/Controllers/VacationRequestController.php index 8d617f87..cff96ee7 100644 --- a/app/Infrastructure/Http/Controllers/VacationRequestController.php +++ b/app/Infrastructure/Http/Controllers/VacationRequestController.php @@ -43,7 +43,7 @@ public function index(Request $request, YearPeriodRetriever $yearPeriodRetriever $vacationRequests = $request->user() ->vacationRequests() - ->with("vacations") + ->with(["user", "vacations"]) ->whereBelongsTo($yearPeriodRetriever->selected()) ->latest() ->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user())) @@ -131,6 +131,7 @@ public function show(VacationRequest $vacationRequest, UserVacationStatsRetrieve { $this->authorize("show", $vacationRequest); + $vacationRequest->load(["user", "vacations", "activities", "activities.user.profile"]); $limit = $statsRetriever->getVacationDaysLimit($vacationRequest->user, $vacationRequest->yearPeriod); $used = $statsRetriever->getUsedVacationDays($vacationRequest->user, $vacationRequest->yearPeriod); $pending = $statsRetriever->getPendingVacationDays($vacationRequest->user, $vacationRequest->yearPeriod); diff --git a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php index 5614d68f..616747b4 100644 --- a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php +++ b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php @@ -36,11 +36,12 @@ protected function getAuthData(Request $request): Closure return fn(): array => [ "user" => $user ? new UserResource($user) : null, - "can" => Permission::all()->mapWithKeys( - fn(Permission $permission): array => [ - $permission->name => $user ? $user->hasPermissionTo($permission) : false, - ], - ), + "can" => Permission::query()->with("roles")->get() + ->mapWithKeys( + fn(Permission $permission): array => [ + $permission->name => $user ? $user->hasPermissionTo($permission) : false, + ], + ), ]; } @@ -63,13 +64,13 @@ protected function getVacationRequestsCount(Request $request): Closure $user = $request->user(); return fn(): ?int => $user && $user->can("listAllRequests") - ? VacationRequest::query() - ->whereBelongsTo($this->yearPeriodRetriever->selected()) - ->states( - VacationRequestStatesRetriever::waitingForUserActionStates($user), - ) - ->count() - : null; + ? VacationRequest::query() + ->whereBelongsTo($this->yearPeriodRetriever->selected()) + ->states( + VacationRequestStatesRetriever::waitingForUserActionStates($user), + ) + ->count() + : null; } protected function getDeployInformation(): Closure 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 ebf59ebf..2aa2d6f9 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", diff --git a/composer.lock b/composer.lock index 2351e64d..ac9f941c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4abd8134fb63cfe21319edf0a8b2985b", + "content-hash": "c8d8df84c5fefa8639edb8deeb5f42c1", "packages": [ { "name": "azuyalabs/yasumi", @@ -79,6 +79,90 @@ ], "time": "2024-01-07T14:12:44+00:00" }, + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.12.2", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "43555503052443964ce2c1c1f3b0378e58219eb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/43555503052443964ce2c1c1f3b0378e58219eb8", + "reference": "43555503052443964ce2c1c1f3b0378e58219eb8", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10|^11", + "illuminate/session": "^9|^10|^11", + "illuminate/support": "^9|^10|^11", + "maximebf/debugbar": "~1.21.0", + "php": "^8.0", + "symfony/finder": "^6|^7" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^5|^6|^7|^8|^9", + "phpunit/phpunit": "^9.6|^10.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.10-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + } + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.12.2" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2024-03-13T09:50:34+00:00" + }, { "name": "barryvdh/laravel-dompdf", "version": "v2.1.1", @@ -3933,6 +4017,72 @@ }, "time": "2023-05-10T11:58:31+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.21.3", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "0b407703b08ea0cf6ebc61e267cc96ff7000911b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/0b407703b08ea0cf6ebc61e267cc96ff7000911b", + "reference": "0b407703b08ea0cf6ebc61e267cc96ff7000911b", + "shasum": "" + }, + "require": { + "php": "^7.1|^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6|^7" + }, + "require-dev": { + "phpunit/phpunit": ">=7.5.20 <10.0", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.21-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "support": { + "issues": "https://github.com/maximebf/php-debugbar/issues", + "source": "https://github.com/maximebf/php-debugbar/tree/v1.21.3" + }, + "time": "2024-03-12T14:23:07+00:00" + }, { "name": "meyfa/php-svg", "version": "v0.9.1", diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore