Clean up frontpage query call (first of many...)

This commit is contained in:
James Cole 2016-03-02 12:09:45 +01:00
parent b317d1a171
commit dbdc334931

View File

@ -177,9 +177,6 @@ class AccountRepository implements AccountRepositoryInterface
} }
/** /**
* This method is used on the front page where (in turn) its viewed journals-tiny.php which (in turn)
* is almost the only place where formatJournal is used. Aka, we can use some custom querying to get some specific.
* fields using left joins.
* *
* @param Account $account * @param Account $account
* @param Carbon $start * @param Carbon $start
@ -191,18 +188,14 @@ class AccountRepository implements AccountRepositoryInterface
{ {
$set = Auth::user() $set = Auth::user()
->transactionjournals() ->transactionjournals()
->with(['transactions']) ->expanded()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')->where('accounts.id', $account->id)
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transaction_journals.transaction_currency_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->before($end) ->before($end)
->after($start) ->after($start)
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC') ->orderBy('transaction_journals.id', 'DESC')
->take(10) ->take(10)
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']); ->get(TransactionJournal::QUERYFIELDS);
return $set; return $set;
} }