First attempt at new last activity thing.

This commit is contained in:
James Cole
2015-07-25 19:22:41 +02:00
parent 3c2952009e
commit c3dc193f3e
2 changed files with 24 additions and 2 deletions

View File

@@ -207,6 +207,27 @@ class AccountRepository implements AccountRepositoryInterface
}
/**
* @param array $accounts
*
* @return array
*/
public function getLastActivities(array $accounts)
{
$list = [];
$set = Auth::user()->transactions()
->whereIn('account_id', $accounts)
->groupBy('account_id')
->get(['transactions.account_id', DB::Raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
foreach ($set as $entry) {
$list[intval($entry->account_id)] = new Carbon($entry->max_date);
}
return $list;
}
/**
* @param Account $account
*