/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($post_id)
 {
     //
     $post = UserPosts::getPostById($post_id);
     if (Auth::check()) {
         $post["liked"] = LikeEvent::checkLiked($post["post_id"], Auth::user()->user_id);
     }
     $post["comments"] = Post::getCommentsByPostId($post_id);
     return response()->json($post);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($post_id)
 {
     //
     $post = $this->getPostDetail($post_id)[0];
     $post_stat = $this->getPostDetail($post_id)[1];
     if (Auth::check()) {
         $post["liked"] = LikeEvent::checkLiked($post["post_id"], Auth::user()->user_id);
     }
     $post["comments"] = Post::getCommentsByPostId($post_id);
     $post["likes"] = $post_stat["likes"];
     $post["pins"] = $post_stat["pins"];
     $post["boards"] = Board::getPostsInBoard($post["board_id"]);
     $post["places"] = Place::getPlaceById(Post::getPostById($post_id)['place_id']);
     $recommend = new RecommendController();
     $post["recommend_posts"] = $recommend->getPost($post_id);
     return response()->json($post);
 }
 public function likePost($post_id)
 {
     if (!Auth::check()) {
         return response()->json('Please login');
     }
     $current_id = Auth::user()->user_id;
     $avatar_link = Auth::user()->avatar_link;
     $name = Auth::user()->name;
     $post = LikeEvent::checkLiked($post_id, $current_id);
     $channel = Post::getPostById($post_id)["user_id"];
     if (!$post) {
         $result = LikeEvent::createLikeEvent($post_id, $current_id);
         $pusher = App::make('pusher');
         $pusher->trigger($channel, 'like', array('name' => $name, 'post_id' => $post_id, 'avatar_link' => $avatar_link));
     } else {
         $result = LikeEvent::removeLikeEvent($post["like_event_id"]);
     }
     return response()->json(["result" => $result]);
 }
 public function likePost($post_id)
 {
     if (!Auth::check()) {
         return response()->json('Please login');
     }
     $current_id = Auth::user()->user_id;
     $post = LikeEvent::checkLiked($post_id, $current_id);
     if (!$post) {
         $result = LikeEvent::createLikeEvent($post_id, $current_id);
     } else {
         $result = LikeEvent::removeLikeEvent($post["like_event_id"]);
     }
     return response()->json(["result" => $result]);
 }