fixed n+1
This commit is contained in:
parent
434bd1462f
commit
a42429bf12
@ -19,7 +19,7 @@ class Accounts extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$accounts = Account::collect();
|
$accounts = Account::with('income_transactions', 'expense_transactions')->collect();
|
||||||
|
|
||||||
return $this->response('banking.accounts.index', compact('accounts'));
|
return $this->response('banking.accounts.index', compact('accounts'));
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ class Reconciliations extends Controller
|
|||||||
$started = explode(' ', $started_at)[0] . ' 00:00:00';
|
$started = explode(' ', $started_at)[0] . ' 00:00:00';
|
||||||
$ended = explode(' ', $ended_at)[0] . ' 23:59:59';
|
$ended = explode(' ', $ended_at)[0] . ' 23:59:59';
|
||||||
|
|
||||||
$transactions = Transaction::where('account_id', $account->id)->whereBetween('paid_at', [$started, $ended])->get();
|
$transactions = Transaction::with('account', 'contact')->where('account_id', $account->id)->whereBetween('paid_at', [$started, $ended])->get();
|
||||||
|
|
||||||
return collect($transactions)->sortByDesc('paid_at');
|
return collect($transactions)->sortByDesc('paid_at');
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class Vendors extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle payments
|
// Handle payments
|
||||||
$transactions = Transaction::with('category')->where('contact_id', $vendor->id)->expense()->get();
|
$transactions = Transaction::with('account', 'category')->where('contact_id', $vendor->id)->expense()->get();
|
||||||
|
|
||||||
$counts['transactions'] = $transactions->count();
|
$counts['transactions'] = $transactions->count();
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class Customers extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle transactions
|
// Handle transactions
|
||||||
$transactions = Transaction::with('category')->where('contact_id', $customer->id)->income()->get();
|
$transactions = Transaction::with('account', 'category')->where('contact_id', $customer->id)->income()->get();
|
||||||
|
|
||||||
$counts['transactions'] = $transactions->count();
|
$counts['transactions'] = $transactions->count();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user