<?php

namespace App\Transformers\Advisories;

use App\Models\Advisories\AdvisoryMember;
use App\Transformers\Companies\CompanyMemberTransformer;
use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract;

class AdvisoryMemberTransformer extends TransformerAbstract {
    protected array $defaultIncludes = [];

    protected array $availableIncludes = [
        'advisory', 'companyMember'
    ];

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

    public function includeAdvisory(AdvisoryMember $model): ?Item {
        return $model->advisory ? $this->item($model->advisory, new AdvisoryTransformer()) : null;
    }

    public function includeCompanyMember(AdvisoryMember $model): ?Item {
        return $model->companyMember ? $this->item($model->companyMember, new CompanyMemberTransformer()) : null;
    }


}