我正在尝试skip and take
在 Laravel 5 中使用功能...当我只使用take()
它时会找到但如果我添加skip()
它不会...
这是我的代码:
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)->skip(20)->take(20);
};
//QUERY FOR COMMENTS AND PROJECT_COMMENT
$commentsCondition = function($q){
$q->where('project_id',$this->id)->where('order',$this->what)->orderBy('comments.id', 'DESC')-skip(20)->take(20);
};
//RETURN PROJECT WITH COMMENTS
$results = Project::with(['comments' => $commentsCondition,'groups' => $userCondition])
->whereHas('groups', $userCondition)
->whereHas('comments', $commentsCondition)
->get();
return $results;
}
当我添加skip()
它时,它只返回空白页而没有错误。