2016-05-02 19:02:15 +02:00
|
|
|
<?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)
|
|
|
|
{
|
2016-05-03 22:02:29 +02:00
|
|
|
return array_merge($this->getDefaults($document), [
|
2016-05-02 19:02:15 +02:00
|
|
|
'id' => (int) $document->public_id,
|
|
|
|
'name' => $document->name,
|
|
|
|
'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,
|
2016-06-01 13:36:27 +02:00
|
|
|
'updated_at' => $this->getTimestamp($document->updated_at),
|
2016-05-03 22:02:29 +02:00
|
|
|
]);
|
2016-05-02 19:02:15 +02:00
|
|
|
}
|
2016-06-01 13:35:53 +02:00
|
|
|
}
|