accounts = $accounts; $this->user = $user; $this->start = $start; $this->end = $end; } /** * @return Collection */ public function collect() { // get all the journals: $ids = $this->accounts->pluck('id')->toArray(); return $this->user->transactionjournals() ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->whereIn('transactions.account_id', $ids) ->before($this->end) ->after($this->start) ->orderBy('transaction_journals.date') ->get(['transaction_journals.*']); } }