Files
ntspi-app/app/Http/Resources/SubSectionResource.php
T
2024-09-19 16:06:49 +05:00

26 lines
652 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class SubSectionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'title' => $this->title,
'pages' => ClientPageNavigateResource::collection($this->whenLoaded('pages')),
'main_section' => $this->mainSection->title ?? null,
'created_at' => $this->created_at->diffforhumans(),
];
}
}