<?php

namespace App\Transformers\Dictionaries;

use App\Models\Dictionaries\DictionaryItem;
use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract;

class DictionaryItemTransformer extends TransformerAbstract {
    protected array $defaultIncludes = [

    ];

    protected array $availableIncludes = [
        'dictionary'
    ];

    public function transform(DictionaryItem $model): array {
        return [
            'id' => $model->uuid,
            'name' => $model->name,
            'title' => $model->title
        ];
    }

    public function includeDictionary(DictionaryItem $model): ?Item {
        return $model->dictionary ? $this->item($model->dictionary, new DictionaryTransformer()) : null;
    }


}
