From 14d1d0adc363bc24aee419475b67807863e00ecb Mon Sep 17 00:00:00 2001 From: liapples Date: Fri, 23 Jul 2021 11:30:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ArticleController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/ArticleController.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/Http/Controllers/Api/ArticleController.php diff --git a/app/Http/Controllers/Api/ArticleController.php b/app/Http/Controllers/Api/ArticleController.php new file mode 100644 index 0000000..c2f0286 --- /dev/null +++ b/app/Http/Controllers/Api/ArticleController.php @@ -0,0 +1,35 @@ +agent_id) + ->select('id', 'image', 'title', 'updated_at') + ->orderBy('id', 'DESC') + ->simplePaginate(15); + return $this->success($list); + } + + //文章详情 + public function show() + { + $id = request()->input('id'); + if (!$id || !ctype_digit($id)) { + return $this->error('未指定文章ID'); + } + + $article = Article::where('agent_id', $this->agent_id)->find($id); + if (!$article) { + return $this->error('文章不存在或已被删除'); + } + return $this->success($article); + } +}