mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Added DocumentTransformer
This commit is contained in:
parent
6acddfc3c7
commit
325cac1603
21
app/Ninja/Transformers/DocumentTransformer.php
Normal file
21
app/Ninja/Transformers/DocumentTransformer.php
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user