From fb0510ada9af0996c2682b8a07956305b9edf873 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Sun, 18 Sep 2022 16:21:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=9B=BA=E9=92=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ForumController.php | 12 +++++++++++- routes/api.php | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ForumController.php b/app/Http/Controllers/ForumController.php index d467a2c..ab9a465 100644 --- a/app/Http/Controllers/ForumController.php +++ b/app/Http/Controllers/ForumController.php @@ -36,6 +36,15 @@ public function announcements() return $this->resp($resp); } + public function pinned() + { + $resp = $this->cache(function () { + return $this->get('discussions?filter[tag]=pinned&page[offset]=0&sort=-commentCount'); + }); + + return $this->resp($resp); + } + public function cache(Closure $callback) { @@ -48,7 +57,8 @@ public function cache(Closure $callback) } - public function resp($data) { + public function resp($data) + { $data['base_url'] = $this->baseUrl; return $this->success($data); diff --git a/routes/api.php b/routes/api.php index 6bc8695..88b3581 100644 --- a/routes/api.php +++ b/routes/api.php @@ -89,6 +89,10 @@ $router->get('/announcements', [ 'uses' => 'ForumController@announcements' ]); + + $router->get('/pinned', [ + 'uses' => 'ForumController@pinned' + ]); }); $router->group(['prefix' => 'modules/{module}'], function () use ($router) {