<?php

namespace App\Transformers\Companies;

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

class BankDetailsTransformer extends TransformerAbstract {
    protected array $defaultIncludes = [

    ];

    protected array $availableIncludes = [
        'company'
    ];

    public function transform(BankDetails $model): array {
        return [
            'id' => $model->uuid,
            'bik' => $model->bik,
            'bank' => $model->bank,
            'address' => $model->address,
            'checking_account' => $model->checking_account,
            'correspondent_account' => $model->correspondent_account
        ];
    }

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


}
