mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
API optimizations
This commit is contained in:
parent
82bfbce56a
commit
3594d1bea0
@ -206,6 +206,8 @@ class BaseAPIController extends Controller
|
|||||||
$data[] = 'clients.contacts';
|
$data[] = 'clients.contacts';
|
||||||
} elseif ($include == 'vendors') {
|
} elseif ($include == 'vendors') {
|
||||||
$data[] = 'vendors.vendor_contacts';
|
$data[] = 'vendors.vendor_contacts';
|
||||||
|
} elseif ($include == 'documents' && $this->entityType == ENTITY_INVOICE) {
|
||||||
|
$data[] = 'documents.expense';
|
||||||
} elseif ($include) {
|
} elseif ($include) {
|
||||||
$data[] = $include;
|
$data[] = $include;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ class DocumentTransformer extends EntityTransformer
|
|||||||
'name' => $document->name,
|
'name' => $document->name,
|
||||||
'type' => $document->type,
|
'type' => $document->type,
|
||||||
'path' => $document->path,
|
'path' => $document->path,
|
||||||
'invoice_id' => isset($document->invoice->public_id) ? (int) $document->invoice->public_id : null,
|
'invoice_id' => $document->invoice_id && $document->invoice ? (int) $document->invoice->public_id : null,
|
||||||
'expense_id' => isset($document->expense->public_id) ? (int) $document->expense->public_id : null,
|
'expense_id' => $document->expense_id && $document->expense ? (int) $document->expense->public_id : null,
|
||||||
'updated_at' => $this->getTimestamp($document->updated_at),
|
'updated_at' => $this->getTimestamp($document->updated_at),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,11 @@ class ExpenseTransformer extends EntityTransformer
|
|||||||
{
|
{
|
||||||
$transformer = new DocumentTransformer($this->account, $this->serializer);
|
$transformer = new DocumentTransformer($this->account, $this->serializer);
|
||||||
|
|
||||||
|
$expense->documents->each(function ($document) use ($expense) {
|
||||||
|
$document->setRelation('expense', $expense);
|
||||||
|
$document->setRelation('invoice', $expense->invoice);
|
||||||
|
});
|
||||||
|
|
||||||
return $this->includeCollection($expense->documents, $transformer, ENTITY_DOCUMENT);
|
return $this->includeCollection($expense->documents, $transformer, ENTITY_DOCUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
{
|
{
|
||||||
$transformer = new DocumentTransformer($this->account, $this->serializer);
|
$transformer = new DocumentTransformer($this->account, $this->serializer);
|
||||||
|
|
||||||
|
$invoice->documents->each(function ($document) use ($invoice) {
|
||||||
|
$document->setRelation('invoice', $invoice);
|
||||||
|
});
|
||||||
|
|
||||||
return $this->includeCollection($invoice->documents, $transformer, ENTITY_DOCUMENT);
|
return $this->includeCollection($invoice->documents, $transformer, ENTITY_DOCUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user