32 lines
703 B
PHP
32 lines
703 B
PHP
<?php
|
|
|
|
namespace App\Transformers\Dictionaries;
|
|
|
|
use App\Models\Dictionaries\Dictionary;
|
|
use League\Fractal\Resource\Collection;
|
|
use League\Fractal\TransformerAbstract;
|
|
|
|
class DictionaryTransformer extends TransformerAbstract {
|
|
protected array $defaultIncludes = [
|
|
|
|
];
|
|
|
|
protected array $availableIncludes = [
|
|
'items'
|
|
];
|
|
|
|
public function transform(Dictionary $model): array {
|
|
return [
|
|
'id' => $model->uuid,
|
|
'name' => $model->name,
|
|
'title' => $model->title
|
|
];
|
|
}
|
|
|
|
public function includeItems(Dictionary $model): Collection {
|
|
return $this->collection($model->items, new DictionaryItemTransformer());
|
|
}
|
|
|
|
|
|
}
|