more eager loading
This commit is contained in:
@ -26,7 +26,7 @@ class Customers extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$customers = Contact::customer()->collect();
|
||||
$customers = Contact::with('invoices.transactions')->customer()->collect();
|
||||
|
||||
return view('sales.customers.index', compact('customers'));
|
||||
}
|
||||
@ -49,7 +49,7 @@ class Customers extends Controller
|
||||
$counts = [];
|
||||
|
||||
// Handle invoices
|
||||
$invoices = Invoice::where('contact_id', $customer->id)->get();
|
||||
$invoices = Invoice::with('transactions')->where('contact_id', $customer->id)->get();
|
||||
|
||||
$counts['invoices'] = $invoices->count();
|
||||
|
||||
@ -76,7 +76,7 @@ class Customers extends Controller
|
||||
}
|
||||
|
||||
// Handle transactions
|
||||
$transactions = Transaction::where('contact_id', $customer->id)->income()->get();
|
||||
$transactions = Transaction::with('category')->where('contact_id', $customer->id)->income()->get();
|
||||
|
||||
$counts['transactions'] = $transactions->count();
|
||||
|
||||
|
Reference in New Issue
Block a user