1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Transformers/DocumentTransformer.php
David Bomba c6e1658ffe
Refactors (#3148)
* Refactor company properties to be presented from settings object instead of company properties

* Working on Email Tests

* Working on emails

* Working on email templats

* Include text version of email

* Refactor Email template builder into trait'

* Fix for custom_value4

* Refactor payment_date -> date && payment_type_id -> type_id

* expose paymentables to API

* expose paymentables to API

* Implement a next_send_date field in invoice/quote tables to allow control over reminder scheduling

* Add custom_values to users,documents and company_gateways tables
2019-12-16 22:34:38 +11:00

56 lines
1.7 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @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),
'path' => (string) $document->path ?: '',
'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,
'archived_at' => (int) $document->archived_at
];
}
}