$topic->id, 'title' => $topic->title, 'body' => $topic->body, 'user_id' => (int)$topic->user_id, 'category_id' => (int)$topic->category_id, 'reply_count' => (int)$topic->reply_count, 'view_count' => (int)$topic->view_count, 'last_reply_user_id' => (int)$topic->last_reply_user_id, 'excerpt' => $topic->excerpt, 'slug' => $topic->slug, 'created_at' => $topic->created_at instanceof Carbon ? $topic->created_at->toDateTimeString() : $topic->created_at, 'updated_at' => $topic->updated_at instanceof Carbon ? $topic->updated_at->toDateTimeString() : $topic->updated_at, ]; } public function includeCategory(Topic $topic) { return $this->item($topic->category, new CategoryTransformer()); } public function includeUser(Topic $topic) { return $this->item($topic->user, new UserTransformer()); } }