mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Merge pull request #14164 from marcusmoore/bug/sc-20686
Avoid unnecessarily hydrating models on asset show page
This commit is contained in:
commit
45b253a57d
|
@ -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