*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'title' => $this->title, 'content' => $this->content, 'category_id' => $this->category_id, 'category' => new CategoryResource($this->whenLoaded('category')), 'tags' => new TagCollection($this->whenLoaded('tags')), 'created_at' => $this->created_at->toDateTimeString(), 'updated_at' => $this->updated_at->toDateTimeString(), ]; } }