From f5dafc477a8b38d3b42f1a8769b019be7dc44e05 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 24 Jan 2024 16:14:51 -0800 Subject: [PATCH] Avoid unnecessary model hydration on asset model show page --- app/Http/Controllers/AssetModelsController.php | 2 +- resources/views/models/view.blade.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 5ac958a8ac..012f40e399 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -288,7 +288,7 @@ class AssetModelsController extends Controller public function show($modelId = null) { $this->authorize('view', AssetModel::class); - $model = AssetModel::withTrashed()->find($modelId); + $model = AssetModel::withTrashed()->withCount('assets')->find($modelId); if (isset($model->id)) { return view('models/view', compact('model')); diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index 29cfd99c11..a98e14b4ee 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -43,7 +43,7 @@ @@ -342,7 +342,7 @@ @endcan @can('delete', \App\Models\AssetModel::class) - @if ($model->assets->count() > 0) + @if ($model->assets_count > 0)