Exemplo n.º 1
0
 /**
  * Update the specified resource in storage. If it has been deleted, this will undelete it.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Comment $comment)
 {
     if (!Auth::user()->can('create-comments')) {
         abort(401, 'You do not have permission to update a comment');
     }
     if (!$comment) {
         abort(400, 'Comment does not exist');
     }
     if ($comment->user->id != Auth::user()->id && !Auth::user()->can('administrate-comment')) {
         abort(401, 'User does not have permission to edit this comment');
     }
     $comment->secureFill(Request::except('token'));
     if (!$comment->save()) {
         //Validation failed show errors
         abort(403, $comment->errors);
     }
     return $comment;
 }