From 7b1265cb89eab0c174754cccd183e5e96aef452c Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 31 May 2017 02:02:55 -0700 Subject: [PATCH] Cache totals for later dashboard use --- app/Http/Controllers/DashboardController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index c863df05a5..d043b9c7f8 100755 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -32,15 +32,18 @@ class DashboardController extends Controller $asset_stats=null; - + $counts['asset'] = \App\Models\Asset::count(); + $counts['accessory'] = \App\Models\Accessory::count(); + $counts['license'] = \App\Models\License::assetcount(); + $counts['consumable'] = \App\Models\Consumable::count(); + $counts['grand_total'] = $counts['asset'] + $counts['accessory'] + $counts['license'] + $counts['consumable']; if ((!file_exists(storage_path().'/oauth-private.key')) || (!file_exists(storage_path().'/oauth-public.key'))) { \Artisan::call('passport:install'); \Artisan::call('migrate', ['--force' => true]); } - - return View::make('dashboard')->with('asset_stats', $asset_stats); + return View::make('dashboard')->with('asset_stats', $asset_stats)->with('counts', $counts); } else { // Redirect to the profile page return redirect()->intended('account/view-assets');