From c587081fe4eac5e9e3724f699ff7b2e78408053b Mon Sep 17 00:00:00 2001 From: Balazs Varkonyi Date: Thu, 9 Apr 2015 11:52:35 +0200 Subject: [PATCH] Add savings total for savings widget on dashboard --- app/Http/Controllers/HomeController.php | 8 +++++++- resources/views/index.blade.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 1824d01039..d9acb90548 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -8,6 +8,7 @@ use Input; use Preferences; use Redirect; use Session; +use Steam; /** * Class HomeController @@ -60,6 +61,11 @@ class HomeController extends Controller $accounts = $repository->getFrontpageAccounts($frontPage); $savings = $repository->getSavingsAccounts(); + $savingsTotal = 0; + foreach ($savings as $savingAccount) { + $savingsTotal += Steam::balance($savingAccount); + } + // check if all books are correct. $sum = $repository->sumOfEverything(); if ($sum != 0) { @@ -77,7 +83,7 @@ class HomeController extends Controller } } - return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions')); + return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal')); } diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 7773963ef2..cc4a001e1b 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -55,6 +55,7 @@
Savings + {!! Amount::format($savingsTotal) !!}
@if(count($savings) == 0)