mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Use scoped query for asset count
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
c5a6cec194
commit
d45d322b54
|
@ -1147,6 +1147,27 @@ class Asset extends Depreciable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query builder scope for Archived assets
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function scopeAssetsForShow($query)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Setting::getSettings()->show_archived_in_list!=1) {
|
||||||
|
return $query->whereHas('assetstatus', function ($query) {
|
||||||
|
$query->where('archived', '=', 0);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query builder scope for Archived assets
|
* Query builder scope for Archived assets
|
||||||
*
|
*
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<a href="#items" data-toggle="tab" title="{{ trans('general.items') }}"> {{ ucwords($category_type_route) }}
|
<a href="#items" data-toggle="tab" title="{{ trans('general.items') }}"> {{ ucwords($category_type_route) }}
|
||||||
@if ($category->category_type=='asset')
|
@if ($category->category_type=='asset')
|
||||||
<badge class="badge badge-secondary"> {{ $category->assets->count() }}</badge>
|
<badge class="badge badge-secondary"> {{ $category->assets()->AssetsForShow()->count() }}</badge>
|
||||||
@endif
|
@endif
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<!-- small box -->
|
<!-- small box -->
|
||||||
<div class="small-box bg-teal">
|
<div class="small-box bg-teal">
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<h3>{{ number_format($counts['asset']) }}</h3>
|
<h3>{{ number_format(\App\Models\Asset::AssetsForShow()->count()) }}</h3>
|
||||||
<p>{{ strtolower(trans('general.assets')) }}</p>
|
<p>{{ strtolower(trans('general.assets')) }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="icon" aria-hidden="true">
|
<div class="icon" aria-hidden="true">
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="hidden-xs hidden-sm">
|
<span class="hidden-xs hidden-sm">
|
||||||
{{ trans('general.assets') }}
|
{{ trans('general.assets') }}
|
||||||
{!! (($location->assets) && ($location->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($location->assets->count()).'</badge>' : '' !!}
|
{!! (($location->assets) && ($location->assets()->AssetsForShow()->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($location->assets()->AssetsForShow()->count()).'</badge>' : '' !!}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="hidden-xs hidden-sm">
|
<span class="hidden-xs hidden-sm">
|
||||||
{{ trans('general.assets') }}
|
{{ trans('general.assets') }}
|
||||||
{!! (($supplier->assets) && ($supplier->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($supplier->assets->count()).'</badge>' : '' !!}
|
{!! (($supplier->assets) && ($supplier->assets()->AssetsForShow()->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($supplier->assets()->AssetsForShow()->count()).'</badge>' : '' !!}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in a new issue