mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Avoid unnecessary model hydration on asset model show page
This commit is contained in:
parent
57a8630e99
commit
f5dafc477a
|
@ -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'));
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
</span>
|
||||
<span class="hidden-xs hidden-sm">
|
||||
{{ trans('general.assets') }}
|
||||
{!! (($model->assets) && ($model->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($model->assets->count()).'</badge>' : '' !!}
|
||||
{!! (($model->assets_count) && ($model->assets_count > 0 )) ? '<badge class="badge badge-secondary">'.number_format($model->assets_count).'</badge>' : '' !!}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
@ -342,7 +342,7 @@
|
|||
@endcan
|
||||
|
||||
@can('delete', \App\Models\AssetModel::class)
|
||||
@if ($model->assets->count() > 0)
|
||||
@if ($model->assets_count > 0)
|
||||
|
||||
<div class="col-md-12" style="padding-bottom: 5px;">
|
||||
<button class="btn btn-block btn-sm btn-danger hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.cannot_be_deleted') }}">{{ trans('general.delete') }}</button>
|
||||
|
|
Loading…
Reference in a new issue