<?php

namespace App\Transformers\Companies;

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

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

    protected array $availableIncludes = [
        'company'
    ];

    public function transform(Address $model): array {
        return [
            'id' => $model->uuid,
            'type' => $model->type,
            'full' => $model->full,
            'postcode' => $model->postcode,
            'country' => $model->country,
            'region' => $model->region,
            'city' => $model->city,
            'district' => $model->district,
            'street' => $model->street,
            'house' => $model->house,
            'block' => $model->block,
            'office' => $model->office
        ];
    }

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


}
