26 lines
607 B
PHP
26 lines
607 B
PHP
<?php
|
|
|
|
namespace App\Transformers;
|
|
|
|
use App\Models\Tarif;
|
|
use League\Fractal\TransformerAbstract;
|
|
|
|
class TarifTransformer extends TransformerAbstract
|
|
{
|
|
private $locale;
|
|
|
|
public function __construct($locale)
|
|
{
|
|
$this->locale = $locale;
|
|
}
|
|
|
|
public function transform(Tarif $tarif)
|
|
{
|
|
return [
|
|
'id' => $tarif->id,
|
|
'type' => $tarif->type,
|
|
'title' => $tarif->getTranslations('title', [$this->locale])[$this->locale] ?? '-',
|
|
'prices' => $tarif->getTranslations('prices', [$this->locale])[$this->locale] ?? [],
|
|
];
|
|
}
|
|
} |