public function messageComment($message_id) { $message_comments = MessageComment::where('message_id', '=', $message_id); foreach ($message_comments as $message_comment) { $message_comment['avatar'] = User::find($message_comment['user_id'])->avatar; $message_comment['username'] = User::find($message_comment['user_id'])->username; } return View::make('回复信息')->with(array('message_comments' => $message_comments, 'links' => $this->link())); }
public function run() { MessageComment::create(['sender_id' => 1, 'receiver_id' => 2, 'message_id' => 1, 'content' => '戏剧带给你不一样的生活体验,发扬传统文化,传承中国文明,应好好珍惜现在的好时代,去到外面,漂洋过海。']); MessageComment::create(['sender_id' => 1, 'receiver_id' => 3, 'message_id' => 1, 'content' => '戏剧带给你不一样的生活体验,发扬传统文化,传承中国文明,应好好珍惜现在的好时代,去到外面,漂洋过海。']); MessageComment::create(['sender_id' => 3, 'receiver_id' => 1, 'message_id' => 1, 'content' => '戏剧带给你不一样的生活体验,发扬传统文化,传承中国文明,应好好珍惜现在的好时代,去到外面,漂洋过海。']); }
public function deleteMsgComment() { if (!Auth::check()) { return Response::json(array('errCode' => 1, 'message' => '请登录!')); } $user_id = Input::get('user_id'); $msg_comment_id = Input::get('msg_comment_id'); $msg_comment = MessageComment::find($msg_comment_id); // dd($msg_comment->sender_id); if ($msg_comment == null) { return Response::json(array('errCode' => 2, 'message' => '该留言回复不存在!')); } ////判断是否在自己的个人空间 if (Auth::user()->id == $user_id) { if (!$msg_comment->delete()) { return Response::json(array('errCode' => 3, 'message' => '删除失败!')); } return Response::json(array('errCode' => 0, 'message' => '删除成功!')); } //在别人的个人空间中,只能删除自己的留言回复 $sender_id = $msg_comment->sender_id; if (Auth::user()->id != $sender_id) { return Response::json(array('errCode' => 4, 'message' => '[权限禁止]只能删除自己的留言回复')); } if (!$msg_comment->delete()) { return Response::json(array('errCode' => 5, 'message' => '删除失败!')); } return Response::json(array('errCode' => 0, 'message' => '删除成功!')); }