InvoiceReport: avoid additional queries in the result items loop

(cherry picked from commit 9fd6ac0d7108a7e19faa5b3eae360974c1093d73)
This commit is contained in:
Aleksander V. Dyomin 2019-08-05 12:33:04 +03:00
parent a469870b2a
commit 4476c9eea2

View File

@ -56,7 +56,7 @@ class InvoiceReport extends AbstractReport
$clients = Client::scope() $clients = Client::scope()
->orderBy('name') ->orderBy('name')
->withArchived() ->withArchived()
->with('contacts', 'user') ->with('contacts', 'user', 'country', 'shipping_country')
->with(['invoices' => function ($query) use ($statusIds) { ->with(['invoices' => function ($query) use ($statusIds) {
$query->invoices() $query->invoices()
->withArchived() ->withArchived()
@ -122,7 +122,7 @@ class InvoiceReport extends AbstractReport
$invoice->po_number, $invoice->po_number,
$invoice->private_notes, $invoice->private_notes,
$client->vat_number, $client->vat_number,
$invoice->user->getDisplayName(), $client->user->getDisplayName(),
trim(str_replace('<br/>', ', ', $client->present()->address()), ', '), trim(str_replace('<br/>', ', ', $client->present()->address()), ', '),
trim(str_replace('<br/>', ', ', $client->present()->address(ADDRESS_SHIPPING)), ', '), trim(str_replace('<br/>', ', ', $client->present()->address(ADDRESS_SHIPPING)), ', '),
]; ];