Added transactions relation for n+1 issues..
This commit is contained in:
parent
c6716e7763
commit
7e5a64262c
|
|
@ -207,7 +207,7 @@ trait Documents
|
|||
$today = Date::today()->toDateString();
|
||||
|
||||
// Eager load transactions with currency to prevent N+1 queries when calling getAmountConvertedToDefault()
|
||||
$documents = $documents ?: Document::type($type)->with(['transactions.currency'])->future();
|
||||
$documents = $documents ?: Document::type($type)->with(['transactions', 'transactions.currency'])->future();
|
||||
|
||||
$documents->each(function ($document) use (&$totals, $today) {
|
||||
if (! in_array($document->status, $this->getDocumentStatusesForFuture())) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Content extends Component
|
|||
$docs = $this->contact->isCustomer() ? 'invoices' : 'bills';
|
||||
|
||||
// Eager load transactions with currency to prevent N+1 queries when calling getAmountConvertedToDefault()
|
||||
$this->documents = $this->contact->$docs()->with(['transactions.currency'])->get();
|
||||
$this->documents = $this->contact->$docs()->with(['transactions', 'transactions.currency'])->get();
|
||||
|
||||
$this->counts['documents'] = $this->documents->count();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue