コード例 #1
0
 public function deleteComment($comment_id)
 {
     $noti = DB::table("comments")->select("notication_id")->where("id", $comment_id)->get();
     $comment_deleted = CommentFacade::deleteComment($comment_id);
     if ($noti) {
         DB::table("notications")->where("id", $noti[0]->notication_id)->delete();
     }
     return $comment_deleted;
 }
コード例 #2
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;
 }
コード例 #3
0
 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;
 }