more eager loading
This commit is contained in:
@@ -11,7 +11,7 @@ class AccountBalance extends Widget
|
||||
|
||||
public function show()
|
||||
{
|
||||
$accounts = Account::enabled()->take(5)->get();
|
||||
$accounts = Account::with(['income_transactions', 'expense_transactions'])->enabled()->take(5)->get();
|
||||
|
||||
return $this->view('widgets.account_balance', [
|
||||
'accounts' => $accounts,
|
||||
|
||||
@@ -22,7 +22,7 @@ class TotalExpenses extends Widget
|
||||
$current += $transaction->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
$this->applyFilters(Bill::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open, &$overdue) {
|
||||
$this->applyFilters(Bill::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open, &$overdue) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($bill);
|
||||
|
||||
$open += $open_tmp;
|
||||
|
||||
@@ -22,7 +22,7 @@ class TotalIncome extends Widget
|
||||
$current += $transaction->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
$this->applyFilters(Invoice::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open, &$overdue) {
|
||||
$this->applyFilters(Invoice::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open, &$overdue) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($invoice);
|
||||
|
||||
$open += $open_tmp;
|
||||
|
||||
@@ -30,14 +30,14 @@ class TotalProfit extends Widget
|
||||
}
|
||||
});
|
||||
|
||||
$this->applyFilters(Invoice::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open_invoice, &$overdue_invoice) {
|
||||
$this->applyFilters(Invoice::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($invoice) use (&$open_invoice, &$overdue_invoice) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($invoice);
|
||||
|
||||
$open_invoice += $open_tmp;
|
||||
$overdue_invoice += $overdue_tmp;
|
||||
});
|
||||
|
||||
$this->applyFilters(Bill::accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open_bill, &$overdue_bill) {
|
||||
$this->applyFilters(Bill::with('transactions')->accrued()->notPaid(), ['date_field' => 'created_at'])->each(function ($bill) use (&$open_bill, &$overdue_bill) {
|
||||
list($open_tmp, $overdue_tmp) = $this->calculateDocumentTotals($bill);
|
||||
|
||||
$open_bill += $open_tmp;
|
||||
|
||||
Reference in New Issue
Block a user