diff --git a/app/Http/Controllers/Api/TopicsController.php b/app/Http/Controllers/Api/TopicsController.php index 6eb5c4e..ace56eb 100644 --- a/app/Http/Controllers/Api/TopicsController.php +++ b/app/Http/Controllers/Api/TopicsController.php @@ -49,6 +49,11 @@ class TopicsController extends Controller return $this->response->paginator($topics, new TopicTransformer()); } + public function show(Topic $topic) + { + return $this->response->item($topic, new TopicTransformer()); + } + /** * @param Topic $topic * @return \Dingo\Api\Http\Response diff --git a/routes/api.php b/routes/api.php index 2d167ab..6c5e680 100644 --- a/routes/api.php +++ b/routes/api.php @@ -55,6 +55,8 @@ $api->version('v1', [ $api->get('topics', 'TopicsController@index')->name('api.topics.index'); //某用户的话题列表 $api->get('users/{user}/topics', 'TopicsController@userIndex')->name('api.users.topics.index'); + //话题详情 + $api->get('topics/{topic}', 'TopicsController@show')->name('api.topics.show'); }); // 需要 token 验证的接口