public function reply() { if (!Sentry::check()) { return Response::json(array('errCode' => 10, 'message' => '请登录')); } $user = Sentry::getUser(); // $receiver_id = Input::get('receiver_id'); $com_id = Input::get('com_id'); $content = Input::get('content'); // $receiver = User::find($receiver_id); // if(!isset($receiver)) // return Response::json(array('errCode'=>2, 'message'=>'[数据库中没有receiver_id对应的user]被评论者不存在')); if (empty($content)) { return Response::json(array('errCode' => 3, 'message' => '[content没有内容]请填写评论论文!')); } $join_com = ArticleJoinCom::find($com_id); if (!isset($join_com)) { return Response::json(array('errCode' => 4, 'message' => '[com_id对应的评论不存在]你回复的评论不存在!')); } //新增回复 $reply = new ArticleJoinReply(); $reply->receiver_id = $join_com->sender_id; $reply->sender_id = $user->id; $reply->com_id = $com_id; $reply->content = $content; if (!$reply->save()) { return Response::json(array('errCode' => 5, 'message' => '[数据库问题]回复失败!')); } return Response::Json(array('errCode' => 0, 'message' => '回复成功!')); }