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 getProfile($user_id) { $number_of_following = FollowEvent::countFollowing($user_id); $number_of_follower = FollowEvent::countFollower($user_id); $number_of_boards = Board::countBoardsByUserId($user_id); $number_of_posts = Post::countPostsByUserId($user_id); return array("number_of_posts" => $number_of_posts, "number_of_boards" => $number_of_boards, "number_of_follower" => $number_of_follower, "number_of_following" => $number_of_following); }
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; }
public static function countFollower($user_id) { $number_following_id = FollowEvent::where('following_id', $user_id)->count(); return $number_following_id; }
protected static function boot() { parent::boot(); // TODO: Change the autogenerated stub FollowEvent::observe(new NotificationObserver()); }
public function getUserBoards($user_name, $board_name) { $user = User::getUserByName($user_name); if (Auth::check()) { $current_user_id = Auth::user()->user_id; $bool = FollowEvent::checkFollowed($current_user_id, $user["user_id"]); if ($bool == true) { $user["follow"] = "true"; } } $id = $user->user_id; return response()->view("board"); }