error('参数错误。参数应为 2 实际得到'.count($id), 400, 400); } $curr = ArticleCollection::where('collect_id', $id[1]) ->where('article_id', $id[0]) ->first(); if (! $curr) { return $this->error('article not found'); } $data = []; $data['curr'] = new ArticleMapResource($curr); $prev = ArticleCollection::where('collect_id', $id[1]) ->where('id', '<', $curr->id) ->orderBy('id', 'desc') ->first(); if ($prev) { $data['prev'] = new ArticleMapResource($prev); } $next = ArticleCollection::where('collect_id', $id[1]) ->where('id', '>', $curr->id) ->orderBy('id') ->first(); if ($next) { $data['next'] = new ArticleMapResource($next); } return $this->ok($data); } /** * Update the specified resource in storage. * * @return Response */ public function update(Request $request, ArticleCollection $articleCollection) { // } /** * Remove the specified resource from storage. * * @return Response */ public function destroy(ArticleCollection $articleCollection) { // } }