*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'title' => $this->title ?? '', 'content' => $this->content ?? '', 'created_at' => $this->created_at?->toDateString() ?? '', 'comments' => $this->comments->map(function ($comment) { return [ 'id' => $comment->id, 'author_name' => $comment->author_name, 'content' => $comment->content, 'created_at' => $comment->created_at?->toDateTimeString(), ]; }), ]; } }