/** * 获取指定帖子的详细. * * @param int $id * * @return \Illuminate\Http\Response */ public function show($id) { $this->topics->addAvailableInclude('user', ['name', 'avatar']); $topic = $this->topics->skipPresenter()->autoWith()->autoWithRootColumns(array_diff(Topic::$includable, ['body', 'body_original', 'excerpt']))->find($id); if (Auth::check()) { $topic->favorite = $this->topics->userFavorite($topic->id, Auth::id()); $topic->attention = $this->topics->userAttention($topic->id, Auth::id()); $topic->vote_up = $this->topics->userUpVoted($topic->id, Auth::id()); $topic->vote_down = $this->topics->userDownVoted($topic->id, Auth::id()); } return $this->response()->item($topic, new TopicTransformer()); }
/** * Display the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function show($id) { $this->repository->addAvailableInclude('user', ['name', 'avatar']); $data = $this->repository->skipPresenter()->autoWith()->find($id); return $this->response()->item($data, new TopicTransformer()); }