more eager loading
This commit is contained in:
parent
657c86a29c
commit
a16406ea1e
@ -23,7 +23,7 @@ class Users extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = User::with('roles')->collect();
|
||||
$users = User::with(['media', 'roles'])->collect();
|
||||
|
||||
return view('auth.users.index', compact('users'));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class Items extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$items = Item::with('category')->collect();
|
||||
$items = Item::with(['category', 'media'])->collect();
|
||||
|
||||
return view('common.items.index', compact('items'));
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Bills extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$bills = Bill::with('contact')->collect(['billed_at'=> 'desc']);
|
||||
$bills = Bill::with(['contact', 'transactions'])->collect(['billed_at'=> 'desc']);
|
||||
|
||||
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Payments extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$payments = Transaction::with(['account', 'category', 'contact'])->expense()->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
$payments = Transaction::with(['account', 'bill', 'category', 'contact'])->expense()->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
|
||||
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
|
@ -38,7 +38,7 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$invoices = Invoice::with('contact')->collect(['invoice_number'=> 'desc']);
|
||||
$invoices = Invoice::with(['contact', 'transactions'])->collect(['invoice_number'=> 'desc']);
|
||||
|
||||
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Revenues extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$revenues = Transaction::with(['account', 'category', 'contact'])->income()->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
$revenues = Transaction::with(['account', 'category', 'contact', 'invoice'])->income()->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
|
||||
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user