Ejemplo n.º 1
0
 public function getAllPhotoUserFollow($user_id)
 {
     $followed = FollowFacade::getIdUserFollow($user_id);
     unset($followed[count($followed) - 1]);
     $images = DB::table("images")->join("users", "users.id", "=", "images.user_id")->whereIn("images.user_id", $followed)->select("images.*", "users.last_name as user_lastname", "users.first_name as user_firstname", "users.avatar as avatar")->orderBy('images.created_at', 'desc')->get();
     $i = 0;
     while ($i < count($images)) {
         $totalLike = LikeFacade::getLike($images[$i]->id);
         $totalComment = CommentFacade::getAllCommentOfImage($images[$i]->id);
         if (!empty($totalLike)) {
             $images[$i]->likeTotal = [];
             $images[$i]->likeTotal = $totalLike;
         }
         if (count($totalComment) > 0) {
             $images[$i]->commentTotal = $totalComment;
         }
         $i++;
     }
     return $images;
 }
 public function getAllPhoto($user_id)
 {
     $numTotalPost = $this->countNumPostTowWeek();
     $images = DB::table("images")->join('users', 'images.user_id', '=', 'users.id')->leftJoin('likes', function ($join) use($user_id) {
         $join->on('images.id', '=', 'likes.image_id')->where('likes.user_id', '=', $user_id);
     })->select('users.id as user_id', 'users.last_name as user_lastname', 'users.first_name as user_firstname', 'users.avatar as avatar', 'likes.id as like_id', 'likes.user_id as userLikeId', 'images.*')->orderBy('images.created_at', 'desc')->take($numTotalPost)->get();
     $i = 0;
     while ($i < $numTotalPost) {
         $totalLike = LikeFacade::getLike($images[$i]->id);
         $totalComment = CommentFacade::getAllCommentOfImage($images[$i]->id);
         $data = ['user_id' => $user_id, 'user_id_image' => $images[$i]->user_id];
         $images[$i]->follow = FollowFacade::checkFollow($data);
         if (!empty($totalLike)) {
             $images[$i]->likeTotal = [];
             $images[$i]->likeTotal = $totalLike;
         }
         if (count($totalComment) > 0) {
             $images[$i]->commentTotal = $totalComment;
         }
         $i++;
     }
     return $images;
 }
Ejemplo n.º 3
0
 public function getPhotoUserLike($user_id)
 {
     return LikeFacade::getPhotoUserLike($user_id);
 }