From e95703cb181b273b0fdbc5016ab585408c7636c0 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 17:10:07 -0700 Subject: [PATCH] Use eager load --- .../Controllers/Users/UsersController.php | 6 +---- resources/views/users/print.blade.php | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index f1826f1481..31c5a1689d 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -611,11 +611,7 @@ class UsersController extends Controller if ($user) { $this->authorize('view', $user); - return view('users/print') - ->with('assets', $user->assets) - ->with('licenses', $user->licenses) - ->with('accessories', $user->accessories) - ->with('consumables', $user->consumables) + return view('users.print') ->with('show_user', $user) ->with('settings', Setting::getSettings()); } diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 26ed2e8127..858f524b4a 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -81,13 +81,13 @@ - @if ($assets->count() > 0) + @if ($show_user->assets->count() > 0) @php $counter = 1; @endphp
-

{{ trans_choice('general.countable.assets', $assets->count(), ['count' => $assets->count()]) }} +

{{ trans_choice('general.countable.assets', $show_user->assets->count(), ['count' => $show_user->assets->count()]) }}

@@ -119,7 +119,7 @@ {{ trans('general.signature') }} - @foreach ($assets as $asset) + @foreach ($show_user->assets as $asset) @php if ($asset->model->category->getEula()) $eulas[] = $asset->model->category->getEula() @endphp @@ -185,9 +185,10 @@ @endif - @if ($licenses->count() > 0) +{{ $show_user->licenses->count() }} + @if ($show_user->licenses->count() > 0)
-

{{ trans_choice('general.countable.licenses', $licenses->count(), ['count' => $licenses->count()]) }}

+

{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}

licenses as $license) @php if ($license->category->getEula()) $eulas[] = $license->category->getEula() @endphp @@ -240,9 +241,9 @@ @endif - @if ($accessories->count() > 0) + @if ($show_user->accessories->count() > 0)
-

{{ trans_choice('general.countable.accessories', $accessories->count(), ['count' => $accessories->count()]) }}

+

{{ trans_choice('general.countable.accessories', $show_user->accessories->count(), ['count' => $show_user->accessories->count()]) }}

accessories as $accessory) @if ($accessory) @php if ($accessory->category->getEula()) $eulas[] = $accessory->category->getEula() @@ -303,9 +304,9 @@
@endif - @if ($consumables->count() > 0) + @if ($show_user->consumables->count() > 0)
-

{{ trans_choice('general.countable.consumables', $consumables->count(), ['count' => $consumables->count()]) }}

+

{{ trans_choice('general.countable.consumables', $show_user->consumables->count(), ['count' => $show_user->consumables->count()]) }}

consumables as $consumable) @if ($consumable) @php if ($consumable->category->getEula()) $eulas[] = $consumable->category->getEula()