2019-09-22 12:41:43 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-09-22 12:41:43 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-09-22 12:41:43 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-09-22 12:41:43 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Transformers;
|
|
|
|
|
2021-01-19 21:22:14 +01:00
|
|
|
use App\Models\Document;
|
2019-09-22 12:41:43 +02:00
|
|
|
use App\Models\GroupSetting;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
2020-10-28 11:10:49 +01:00
|
|
|
use stdClass;
|
2019-09-22 12:41:43 +02:00
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* class ClientTransformer.
|
2019-09-22 12:41:43 +02:00
|
|
|
*/
|
|
|
|
class GroupSettingTransformer extends EntityTransformer
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
2023-08-21 03:29:31 +02:00
|
|
|
protected array $defaultIncludes = [
|
2022-06-21 11:57:17 +02:00
|
|
|
'documents',
|
2019-09-22 12:41:43 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2023-08-21 03:29:31 +02:00
|
|
|
protected array $availableIncludes = [
|
2019-09-22 12:41:43 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param GroupSetting $group_setting
|
2019-09-22 12:41:43 +02:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(GroupSetting $group_setting)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => $this->encodePrimaryKey($group_setting->id),
|
2020-09-06 11:38:10 +02:00
|
|
|
'name' => (string) $group_setting->name ?: '',
|
2024-01-14 05:05:00 +01:00
|
|
|
'settings' => $group_setting->settings ?: new stdClass(),
|
2020-09-06 11:38:10 +02:00
|
|
|
'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,
|
2019-09-22 12:41:43 +02:00
|
|
|
];
|
|
|
|
}
|
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);
|
|
|
|
}
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|