public function loadmore(Request $request)
 {
     $skip = $request->session()->get('skip');
     $skip = $skip + 8;
     $data = Post::GetPopularPost(LikeEvent::GetMostPost(), $skip);
     $request->session()->put('skip', $skip);
     return $data;
 }
Пример #2
0
 public static function checkLiked($post_id, $user_id)
 {
     $result = LikeEvent::where('post_id', $post_id)->where('user_id', $user_id)->first();
     if ($result) {
         return true;
     } else {
         return false;
     }
     //trigger to notification board
 }
 /**
  * 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]);
 }
Пример #6
0
 protected static function boot()
 {
     parent::boot();
     // TODO: Change the autogenerated stub
     LikeEvent::observe(new NotificationObserver());
 }
 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]);
 }