public static function getPostsByPlaceId($place_id)
 {
     if (isset($place_id)) {
         $lists = UserPosts::where('place_id', $place_id)->get();
     }
     return $lists;
 }
 public static function getPostsByFollowingUserId($user_id)
 {
     if (isset($user_id)) {
         $list_id = FollowEvent::where('follower_id', $user_id)->get(['following_id']);
         return UserPosts::whereIn('user_id', $list_id)->get();
     }
 }
 public static function getPosts($post_id)
 {
     $photo_id = Post::where('post_id', $post_id)->get(['photo_link'])[0]["photo_link"];
     $list_id = PostRecommendView::where("photo_id", $photo_id)->orderBy("rank", "desc")->take(10)->get(["post_id_recommend"]);
     $results = UserPosts::whereIn("post_id", $list_id)->distinct('photo_link')->get();
     return $results;
 }
 public static function getBoardById($board_id)
 {
     $result["board"] = Board::where('board_id', $board_id)->first();
     $result["posts"] = UserPosts::where('board_id', $board_id)->get();
     $result["board"]["cover_link"] = $result["posts"][0]["photo_link"];
     $result["profile"]["number_of_posts"] = Post::where('board_id', $board_id)->count();
     $result["profile"]["number_of_following"] = FollowEvent::countFollower($board_id);
     return $result;
 }
 /**
  * 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);
 }
 public function getPost(Request $request)
 {
     $place_id = $request->input("place_id");
     $post = UserPosts::getPostsByPlaceId($place_id);
     return response()->json($post);
 }
 private function getPostDetail($post_id)
 {
     $post = UserPosts::getPostById($post_id);
     $post_stat = PostDetails::getDetails($post_id);
     return [$post, $post_stat];
 }
 public static function getPosts($post_id)
 {
     $list_id = PostRecommend::where("post_id", $post_id)->orderBy("rank", "desc")->take(10)->get(["post_id_recommend"]);
     $results = UserPosts::whereIn("post_id", $list_id)->get();
     return $results;
 }
 public function getPostsByFollowingUserId($user_id)
 {
     $result = UserPosts::getPostsByFollowingUserId($user_id);
     return response()->json($result);
 }
 public function homeview(Request $request)
 {
     $id = Auth::user()->user_id;
     $list = UserPosts::getPostsByFollowingUserId($id);
     return view('mainpage', ["posts" => $list]);
 }