request->get('cid'); $query = CmsArticle::mk()->where('status', 1); if (is_numeric($categoryId)) { $query->hasWhere('cateids', function ($subQuery) use ($categoryId) { $subQuery->where('cid', $categoryId); }); } $articles = $query->field('id,title,thumb,author,from,view_count,publish_at')->order('sort asc,id desc')->paginate(); $this->success('获取文章列表', $articles); } public function info() { $id = $this->request->get('id'); $article = CmsArticle::mk()->where('id', $id)->find(); if (empty($article)) { $this->error('文章不存在'); } $article->inc('view_count'); $article->save(); $this->success('获取文章详情', $article); } }