Creating a full page transformer with all the data

parent 38fa9968
<?php
namespace Modules\Page\Transformers;
use Illuminate\Http\Resources\Json\Resource;
class FullPageTransformer extends Resource
{
public function toArray($request)
{
$pageData = [
'id' => $this->id,
'template' => $this->template,
'is_home' => $this->template,
];
foreach ($this->translations as $pageTranslation) {
$pageData[$pageTranslation->locale] = $pageTranslation;
}
foreach ($this->tags as $tag) {
$pageData['tags'][] = $tag->name;
}
return $pageData;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment