Creating a page transformer class

parent 4040ae14
<?php
namespace Modules\Page\Transformers;
use Illuminate\Http\Resources\Json\Resource;
class PageTransformer extends Resource
{
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->title,
'slug' => $this->slug,
'created_at' => $this->created_at->format('d-m-Y'),
'urls' => [
'delete_url' => route('api.page.page.destroy', $this->id),
'edit_url' => route('admin.page.page.edit', $this->id),
],
];
}
}
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