first(); if (!$category) { return $this->response()->fail('文章不存在'); } $article = Article::where('category_id', $category->id)->publish()->sort()->first(); if (!$article) { return $this->response()->success(''); } return $this->response()->success(ArticleResource::make($article)); } // 进阶指标 public function cate() { $user = auth('api')->user(); $category = Keyword::where('key', 'category_2')->first(); if (!$category) { return $this->response()->fail('文章不存在'); } $article = Article::with(['partyCate'])->where('category_id', $category->id)->where('party_cate_id', $user->cate_id)->publish()->sort()->first(); if (!$article) { return $this->response()->success(''); } return $this->response()->success(ArticleResource::make($article)); } }