From 3e84d66c8094f16b05bd82494df616a9a5965870 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 19 Apr 2016 06:11:20 -0700 Subject: [PATCH] Re-use settings to prevent 1001 queries --- app/Http/Controllers/ReportsController.php | 3 ++- resources/views/reports/asset.blade.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index d99ad6d3e0..7deac834e4 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -95,6 +95,7 @@ class ReportsController extends Controller */ public function getAssetsReport() { + $settings = \App\Models\Setting::first(); // Grab all the assets $assets = Asset::with( 'model', @@ -109,7 +110,7 @@ class ReportsController extends Controller ->orderBy('created_at', 'DESC') ->get(); - return View::make('reports/asset', compact('assets')); + return View::make('reports/asset', compact('assets'))->with('settings',$settings); } /** diff --git a/resources/views/reports/asset.blade.php b/resources/views/reports/asset.blade.php index 21754c7925..0aee0e7ab5 100644 --- a/resources/views/reports/asset.blade.php +++ b/resources/views/reports/asset.blade.php @@ -37,7 +37,7 @@ {{ trans('admin/hardware/form.manufacturer') }} {{ trans('admin/hardware/form.model') }} {{ trans('general.model_no') }} - @if (\App\Models\Setting::getSettings()->display_asset_name) + @if ($settings->display_asset_name) {{ trans('general.name') }} @endif {{ trans('admin/hardware/table.serial') }} @@ -63,7 +63,7 @@ {{ $asset->model->name }} {{ $asset->model->modelno }} - @if (\App\Models\Setting::getSettings()->display_asset_name) + @if ($settings->display_asset_name) {{ $asset->name }} @endif {{ $asset->serial }} @@ -76,7 +76,7 @@ @endif {{ $asset->purchase_date }} - {{ \App\Models\Setting::first()->default_currency }} + {{ $settings->default_currency }} {{ number_format($asset->purchase_cost) }} @@ -134,7 +134,7 @@ iconsPrefix: 'fa', showRefresh: true, search: true, - pageSize: {{ \App\Models\Setting::getSettings()->per_page }}, + pageSize: {{ $settings->per_page }}, pagination: true, sidePagination: 'client', sortable: true,