<?php

namespace App\Transformers\Companies;

use App\Models\Companies\CompanyType;
use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract;

class CompanyTypeTransformer extends TransformerAbstract {
    protected array $defaultIncludes = [

    ];

    protected array $availableIncludes = [
        'company'
    ];

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

    public function includeCompany(CompanyType $model): ?Item {
        return $model->company ? $this->item($model->company, new CompanyTransformer()) : null;
    }


}
