From 22501cc89ac18be5a45ba6113d9f491456463c06 Mon Sep 17 00:00:00 2001 From: fthvgb1 Date: Sun, 10 Jun 2018 19:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=9D=E9=A2=98=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/TopicsController.php | 5 +++++ routes/api.php | 2 ++ 2 files changed, 7 insertions(+) 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 验证的接口