Files
ntspi-app/app/Containers/Article/UI/WEB/Transformers/PostItemResource.php
T
F4ilji c01016a154 Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
2025-05-12 08:47:43 +05:00

33 lines
964 B
PHP

<?php
namespace App\Containers\Article\UI\WEB\Transformers;
use App\Ship\Resources\JsonResource;
use Carbon\Carbon;
class PostItemResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \App\Ship\Requests\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->title,
'slug' => $this->slug,
'content' => $this->content,
'is_published' => $this->is_published,
'category' => $this->category,
'tags' => TagResource::collection($this->tags()->get()),
'authors' => $this->authors,
'gallery' => $this->images,
'reading_time' => $this->reading_time,
'created_post' => Carbon::parse($this->publish_at)->diffforhumans(),
];
}
}