我试图采取跳过并采取元素...这是我的尝试:

public function orderWhat($what){
           $this->what = $what;
           //QUERY FOR GROUPS AND PRODJECT_GROUP
           $userCondition = function($q){
                        $q->where('user_id',Auth::id())->where('project_id',$this->id)->take(10)->skip(10);
                    };

           //QUERY FOR COMMENTS AND PROJECT_COMMENT     
           $commentsCondition = function($q){
                        $q->where('project_id',$this->id)->where('order',$this->what)->orderBy('comment.id', 'DESC')->take(10)->skip(10);
                    };

                    $limit = function($q){
                        $q->take(10);
                    };
           //RETURN PROJECT WITH COMMENTS        
           $results = Project::with(['comments' => $commentsCondition,'groups' => $userCondition])
                                ->whereHas('groups', $userCondition)
                                ->whereHas('comments', $commentsCondition)

                                ->get();
           return $results;
       }

这将导致此查询,但我不会得到任何结果...

SQL:select * from projects where(select count()from groups inner join project_group on groups.id = project_group.group_id where project_group.project_id = projects.id and user_id = 1 and project_id = 1 limit 10 offset 10)> = 1和(从comments内部连接project_comment中选择count()到comments.id = project_comment.comment_id,其中project_comment.project_id = projects.id和project_id = 1,order = 0 order by comment.id desc limit 10 offset 10)> = 1

如果我删除 offset 它将只需要10个帖子....