2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Transformers;
|
2016-05-02 19:02:15 +02:00
|
|
|
|
|
|
|
use App\Models\Document;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2016-12-29 17:17:17 +01:00
|
|
|
* @SWG\Definition(definition="Document", @SWG\Xml(name="Document"))
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
2016-05-02 19:02:15 +02:00
|
|
|
class DocumentTransformer extends EntityTransformer
|
|
|
|
{
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
|
|
|
|
* @SWG\Property(property="name", type="string", example="Test")
|
|
|
|
* @SWG\Property(property="type", type="string", example="CSV")
|
|
|
|
* @SWG\Property(property="invoice_id", type="integer", example=1)
|
|
|
|
* @SWG\Property(property="updated_at", type="timestamp", example=1451160233, readOnly=true)
|
|
|
|
* @SWG\Property(property="archived_at", type="timestamp", example=1451160233, readOnly=true)
|
|
|
|
*/
|
2016-05-02 19:02:15 +02:00
|
|
|
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,
|
2017-01-30 20:40:43 +01:00
|
|
|
'type' => $document->type,
|
2016-05-02 19:02:15 +02:00
|
|
|
'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
|
|
|
}
|