1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-17 00:22:51 +01:00
invoiceninja/app/Transformers/GroupSettingTransformer.php

62 lines
1.5 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Transformers;
2021-01-19 21:22:14 +01:00
use App\Models\Document;
use App\Models\GroupSetting;
2021-01-19 21:22:14 +01:00
use App\Transformers\DocumentTransformer;
use App\Utils\Traits\MakesHash;
2020-10-28 11:10:49 +01:00
use stdClass;
/**
* class ClientTransformer.
*/
class GroupSettingTransformer extends EntityTransformer
{
use MakesHash;
protected $defaultIncludes = [
2021-01-19 21:22:14 +01:00
'documents'
];
/**
* @var array
*/
protected $availableIncludes = [
];
/**
2020-10-28 11:10:49 +01:00
* @param GroupSetting $group_setting
* @return array
*/
public function transform(GroupSetting $group_setting)
{
return [
'id' => $this->encodePrimaryKey($group_setting->id),
'name' => (string) $group_setting->name ?: '',
2020-10-28 11:10:49 +01:00
'settings' => $group_setting->settings ?: new stdClass,
'created_at' => (int) $group_setting->created_at,
'updated_at' => (int) $group_setting->updated_at,
'archived_at' => (int) $group_setting->deleted_at,
2020-02-27 00:32:44 +01:00
'is_deleted' => (bool) $group_setting->is_deleted,
];
}
2021-01-19 21:22:14 +01:00
public function includeDocuments(GroupSetting $group_setting)
{
$transformer = new DocumentTransformer($this->serializer);
return $this->includeCollection($group_setting->documents, $transformer, Document::class);
}
}