exchange/app/Transformers/PageTransformer.php

25 lines
529 B
PHP
Raw Normal View History

2022-12-08 05:12:07 +00:00
<?php
namespace App\Transformers;
use App\Models\Page;
use League\Fractal\TransformerAbstract;
class PageTransformer extends TransformerAbstract
{
private $locale;
public function __construct($locale)
{
$this->locale = $locale;
}
public function transform(Page $page)
{
return [
'id' => $page->id,
'title' => $page->title,
2022-12-08 05:58:29 +00:00
'content' => html_entity_decode($page->getTranslations('content', [$this->locale])[$this->locale]) ?? '-',
2022-12-08 05:12:07 +00:00
];
}
}