1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Added DocumentTransformer

This commit is contained in:
Hillel Coren 2016-05-02 20:02:15 +03:00
parent 6acddfc3c7
commit 325cac1603

View File

@ -0,0 +1,21 @@
<?php namespace App\Ninja\Transformers;
use App\Models\Account;
use App\Models\Document;
use League\Fractal;
class DocumentTransformer extends EntityTransformer
{
public function transform(Document $document)
{
return [
'id' => (int) $document->public_id,
'name' => $document->name,
'account_key' => $this->account->account_key,
'type' => $document->type,
'invoice_id' => isset($document->invoice->public_id) ? (int) $document->invoice->public_id : null,
'expense_id' => isset($document->expense->public_id) ? (int) $document->expense->public_id : null,
];
}
}