Ejemplo n.º 1
0
 /**
  * Display a listing of the comments.
  *
  * @param int $postId
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function index($postId)
 {
     $post = PostRepository::find($postId, ['id']);
     if (!$post) {
         Session::flash('error', 'The post you were viewing has been deleted.');
         return Response::json(['success' => false, 'code' => 404, 'msg' => 'The post you were viewing has been deleted.', 'url' => URL::route('blog.posts.index')], 404);
     }
     $comments = $post->comments()->get(['id', 'version']);
     $data = [];
     foreach ($comments as $comment) {
         $data[] = ['comment_id' => $comment->id, 'comment_ver' => $comment->version];
     }
     return Response::json(array_reverse($data));
 }
Ejemplo n.º 2
0
 /**
  * Delete an existing post.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $post = PostRepository::find($id);
     $this->checkPost($post);
     $post->delete();
     return Redirect::action('PostController@index')->with('success', 'Your post has been deleted successfully.');
 }