예제 #1
0
 public function deleteComment($comment_id)
 {
     $comment = Comment::findOrFail($comment_id);
     if ($comment->user_id != Auth::user()->id) {
         abort(403, 'unauthorized deletion');
     }
     return json_encode(['success' => $comment->delete() ? 'true' : 'false']);
 }
예제 #2
0
 public function destroy($id)
 {
     if (Request::ajax()) {
         $result['error'] = false;
         try {
             $comment = Comment::findOrFail($id);
             $comment->delete();
         } catch (Exception $e) {
             $result['error'] = true;
         }
         return response()->json($result);
     }
 }
예제 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $idx
  *
  * @return Response
  */
 public function destroy($idx)
 {
     $this->checkParametersEmpty();
     $comment = Comment::findOrFail($idx);
     $comment->delete();
     return $this->getCodeResponse(Response::HTTP_NO_CONTENT);
 }
예제 #4
0
 /**
  * Get post slug.
  *
  * @param  int  $comment_id
  * @return string
  */
 public function getSlug($comment_id)
 {
     return $this->comment->findOrFail($comment_id)->post->slug;
 }
예제 #5
0
 /**
  * Destroy a comment if it exists.
  * 
  * @param  $id
  * @return Response
  */
 public function destroy($id)
 {
     $comment = Comment::findOrFail($id);
     $comment::destroy($id);
     return redirect()->action('CommentController@index');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $comment = Comment::findOrFail($id);
     $comment->delete();
     return $this->getCodeResponse(Response::HTTP_NO_CONTENT);
 }
예제 #7
0
 public function approved($id)
 {
     $comment = Comment::findOrFail($id);
     $this->authorize($comment);
     if ($comment->update(['status' => Comment::STATUS_ACTIVE])) {
         return response()->json(['status' => true]);
     }
     return response()->json(['status' => false])->setStatusCode(404);
 }