mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-23 20:38:46 +00:00
Removed for-loop in favour of "pluck()" aka: RTFM.
This commit is contained in:
@@ -7,7 +7,6 @@ use Carbon\Carbon;
|
|||||||
use DB;
|
use DB;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
@@ -66,13 +65,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
{
|
{
|
||||||
/** @var Collection $set */
|
/** @var Collection $set */
|
||||||
$set = Auth::user()->bills()->orderBy('name', 'ASC')->get();
|
$set = Auth::user()->bills()->orderBy('name', 'ASC')->get();
|
||||||
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
$ids = [];
|
|
||||||
/** @var Account $account */
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$ids[] = $account->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$set = $set->filter(
|
$set = $set->filter(
|
||||||
function (Bill $bill) use ($ids) {
|
function (Bill $bill) use ($ids) {
|
||||||
// get transaction journals from or to any of the mentioned accounts.
|
// get transaction journals from or to any of the mentioned accounts.
|
||||||
@@ -156,12 +149,8 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
$set = DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max)->get(
|
$set = DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max)->get(
|
||||||
['transaction_journal_id']
|
['transaction_journal_id']
|
||||||
);
|
);
|
||||||
$ids = [];
|
$ids = $set->pluck('transaction_journal_id')->toArray();
|
||||||
|
|
||||||
/** @var Transaction $entry */
|
|
||||||
foreach ($set as $entry) {
|
|
||||||
$ids[] = intval($entry->transaction_journal_id);
|
|
||||||
}
|
|
||||||
$journals = new Collection;
|
$journals = new Collection;
|
||||||
if (count($ids) > 0) {
|
if (count($ids) > 0) {
|
||||||
$journals = Auth::user()->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->whereIn('transaction_journals.id', $ids)->get(
|
$journals = Auth::user()->transactionjournals()->transactionTypes([TransactionType::WITHDRAWAL])->whereIn('transaction_journals.id', $ids)->get(
|
||||||
|
|||||||
Reference in New Issue
Block a user