store-manage/app/Http/Resources/TrainBookResource.php

32 lines
866 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class TrainBookResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'category_id' => $this->category_id,
'category' => KeywordResource::make($this->whenLoaded('category')),
'title' => $this->title,
'cover_image' => $this->cover_image,
'description' => $this->description,
'type' => $this->type,
'content' => $this->content,
'video' => $this->video,
'files' => $this->files,
'created_at' => $this->created_at->timestamp,
];
}
}