From 03babfe75c3eab6853becb09a48513d77d819497 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 30 Dec 2015 09:16:53 +0100 Subject: [PATCH] Removed for-loop in favour of "pluck()" aka: RTFM. --- app/Repositories/Account/AccountRepository.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index dcd9a867f1..98dd114014 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -266,16 +266,10 @@ class AccountRepository implements AccountRepositoryInterface */ public function getPiggyBankAccounts() { - $ids = []; - $start = clone Session::get('start', new Carbon); - $end = clone Session::get('end', new Carbon); - $accountIds = DB::table('piggy_banks')->distinct()->get(['piggy_banks.account_id']); - $accounts = new Collection; - - /** @var PiggyBank $id */ - foreach ($accountIds as $id) { - $ids[] = intval($id->account_id); - } + $start = clone Session::get('start', new Carbon); + $end = clone Session::get('end', new Carbon); + $ids = DB::table('piggy_banks')->distinct()->get(['piggy_banks.account_id'])->pluck('account_id')->toArray(); + $accounts = new Collection; $cache = new CacheProperties; $cache->addProperty($ids);