mercredi 23 septembre 2015

Skip() function not working [Laravel 5]

I am trying to use skip and take function in Laravel 5... When I just use take() it will work find but if I add skip() it will not...

Here is my code:

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;
       }

When I add skip() it just return blank page without errors.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire