2019-12-16 12:34:38 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-12-16 12:34:38 +01:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Transformers;
|
|
|
|
|
|
|
|
use App\Models\Document;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
|
|
|
|
class DocumentTransformer extends EntityTransformer
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
protected $serializer;
|
|
|
|
|
|
|
|
protected $defaultIncludes = [];
|
|
|
|
|
|
|
|
protected $availableIncludes = [];
|
|
|
|
|
|
|
|
public function __construct($serializer = null)
|
|
|
|
{
|
|
|
|
$this->serializer = $serializer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function transform(Document $document)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => $this->encodePrimaryKey($document->id),
|
|
|
|
'user_id' => $this->encodePrimaryKey($document->user_id),
|
|
|
|
'assigned_user_id' => $this->encodePrimaryKey($document->assigned_user_id),
|
|
|
|
'project_id' => $this->encodePrimaryKey($document->project_id),
|
|
|
|
'vendor_id' => $this->encodePrimaryKey($document->vendor_id),
|
2020-06-22 13:32:10 +02:00
|
|
|
'url' => (string) $document->generateUrl() ?: '',
|
2019-12-16 12:34:38 +01:00
|
|
|
'preview' => (string) $document->preview ?: '',
|
|
|
|
'name' => (string) $document->name,
|
|
|
|
'type' => (string) $document->type,
|
|
|
|
'disk' => (string) $document->disk,
|
|
|
|
'hash' => (string) $document->hash,
|
|
|
|
'size' => (int) $document->size,
|
|
|
|
'width' => (int) $document->width,
|
|
|
|
'height' => (int) $document->height,
|
|
|
|
'is_default' => (bool) $document->is_default,
|
|
|
|
'updated_at' => (int) $document->updated_at,
|
2020-03-26 09:25:44 +01:00
|
|
|
'archived_at' => (int) $document->deleted_at,
|
2020-02-27 00:32:44 +01:00
|
|
|
'created_at' => (int) $document->created_at
|
2019-12-16 12:34:38 +01:00
|
|
|
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|