Re-use settings to prevent 1001 queries

This commit is contained in:
snipe 2016-04-19 06:11:20 -07:00
parent c4ea4f80b1
commit 3e84d66c80
2 changed files with 6 additions and 5 deletions

View file

@ -95,6 +95,7 @@ class ReportsController extends Controller
*/ */
public function getAssetsReport() public function getAssetsReport()
{ {
$settings = \App\Models\Setting::first();
// Grab all the assets // Grab all the assets
$assets = Asset::with( $assets = Asset::with(
'model', 'model',
@ -109,7 +110,7 @@ class ReportsController extends Controller
->orderBy('created_at', 'DESC') ->orderBy('created_at', 'DESC')
->get(); ->get();
return View::make('reports/asset', compact('assets')); return View::make('reports/asset', compact('assets'))->with('settings',$settings);
} }
/** /**

View file

@ -37,7 +37,7 @@
<th class="col-sm-1">{{ trans('admin/hardware/form.manufacturer') }}</th> <th class="col-sm-1">{{ trans('admin/hardware/form.manufacturer') }}</th>
<th class="col-sm-1">{{ trans('admin/hardware/form.model') }}</th> <th class="col-sm-1">{{ trans('admin/hardware/form.model') }}</th>
<th class="col-sm-1">{{ trans('general.model_no') }}</th> <th class="col-sm-1">{{ trans('general.model_no') }}</th>
@if (\App\Models\Setting::getSettings()->display_asset_name) @if ($settings->display_asset_name)
<th class="col-sm-1">{{ trans('general.name') }}</th> <th class="col-sm-1">{{ trans('general.name') }}</th>
@endif @endif
<th class="col-sm-1">{{ trans('admin/hardware/table.serial') }}</th> <th class="col-sm-1">{{ trans('admin/hardware/table.serial') }}</th>
@ -63,7 +63,7 @@
</td> </td>
<td>{{ $asset->model->name }}</td> <td>{{ $asset->model->name }}</td>
<td>{{ $asset->model->modelno }}</td> <td>{{ $asset->model->modelno }}</td>
@if (\App\Models\Setting::getSettings()->display_asset_name) @if ($settings->display_asset_name)
<td>{{ $asset->name }}</td> <td>{{ $asset->name }}</td>
@endif @endif
<td>{{ $asset->serial }}</td> <td>{{ $asset->serial }}</td>
@ -76,7 +76,7 @@
@endif @endif
</td> </td>
<td>{{ $asset->purchase_date }}</td> <td>{{ $asset->purchase_date }}</td>
<td class="align-right">{{ \App\Models\Setting::first()->default_currency }} <td class="align-right">{{ $settings->default_currency }}
{{ number_format($asset->purchase_cost) }} {{ number_format($asset->purchase_cost) }}
</td> </td>
<td> <td>
@ -134,7 +134,7 @@
iconsPrefix: 'fa', iconsPrefix: 'fa',
showRefresh: true, showRefresh: true,
search: true, search: true,
pageSize: {{ \App\Models\Setting::getSettings()->per_page }}, pageSize: {{ $settings->per_page }},
pagination: true, pagination: true,
sidePagination: 'client', sidePagination: 'client',
sortable: true, sortable: true,