31 lines
664 B
PHP
31 lines
664 B
PHP
<?php
|
|
|
|
namespace App\Transformers\Companies;
|
|
|
|
use App\Models\Companies\Contact;
|
|
use League\Fractal\Resource\Item;
|
|
use League\Fractal\TransformerAbstract;
|
|
|
|
class ContactTransformer extends TransformerAbstract {
|
|
protected array $defaultIncludes = [
|
|
|
|
];
|
|
|
|
protected array $availableIncludes = [
|
|
'company'
|
|
];
|
|
|
|
public function transform(Contact $model): array {
|
|
return [
|
|
'type' => $model->parsedType,
|
|
'value' => $model->value
|
|
];
|
|
}
|
|
|
|
public function includeCompany(Contact $model): ?Item {
|
|
return $model->company ? $this->item($model->company, new CompanyTransformer()) : null;
|
|
}
|
|
|
|
|
|
}
|