From 136bf09fbb8bf999a0b4a236c4f7cf6ab9fcce97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Thu, 25 May 2023 18:01:44 +0300 Subject: [PATCH] N+1 Account index and show fixed.. --- app/Http/Controllers/Banking/Accounts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php index 02b88d8d1..06371636e 100644 --- a/app/Http/Controllers/Banking/Accounts.php +++ b/app/Http/Controllers/Banking/Accounts.php @@ -23,7 +23,7 @@ class Accounts extends Controller */ public function index() { - $accounts = Account::with('income_transactions', 'expense_transactions')->collect(); + $accounts = Account::with('transactions')->collect(); return $this->response('banking.accounts.index', compact('accounts')); } @@ -35,7 +35,7 @@ class Accounts extends Controller */ public function show(Account $account) { - $transactions = Transaction::with('category', 'contact', 'document')->where('account_id', $account->id)->collect(['paid_at'=> 'desc']); + $transactions = Transaction::with('category', 'contact', 'document', 'recurring')->where('account_id', $account->id)->collect(['paid_at'=> 'desc']); $transfers = Transfer::with('expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account') ->whereHas('expense_transaction', fn ($query) => $query->where('account_id', $account->id))