/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request) { try { $reply = $this->repository->create($request->all()); return $this->response()->item($reply, new ReplyTransformer()); } catch (ValidatorException $e) { throw new StoreResourceFailedException('Could not create new topic.', $e->getMessageBag()->all()); } }
/** * 指定帖子下评论列表的 Web View. * * @param $user_id * * @return \Illuminate\View\View */ public function indexWebViewByUser($user_id) { $replies = $this->replies->byUserId($user_id)->withOnly('topic.user', ['avatar'])->all(['id', 'body', 'created_at', 'topic_id']); return view('api_web_views.users_replies_list', compact('replies', 'count')); }