birdietorerik's avatar

Using paginate

Hi! Have created a application using Laravel 10.x and Vue.js

Need to use paginate on frontend

First test is to get only 2 records on frontend, result from this query->model

 public static function getroundsplayer($userid)
    {
    
       $playersrounds = Playersround ::where('userref_id',$userid)
        ->select('playersrounds.*', 'tees.name as teename' , 'golfclubs.name as golfclubname', 'courcegolfclubs.courcename' , 'startlists.*')
        ->join('startlists', 'startlists.id', '=', 'playersrounds.startlist_id')
        ->join('tees', 'tees.id', '=', 'playersrounds.teeref_id')
        ->join('golfclubs', 'golfclubs.id', '=', 'playersrounds.golf_id')
        ->join('courcegolfclubs', 'courcegolfclubs.id', '=', 'playersrounds.sloyferef_id')
        //->groupBy('playersrounds.golf_id','DESC')
        //->orderBy('playersrounds.golf_id', 'ASC')
        ->get();
        
        return $playersrounds->paginate(2);
    }

set paginate to 2 But it dosent show anything on my frontpage ?

0 likes
1 reply
tisuchi's avatar
tisuchi
Best Answer
Level 70

@birdietorerik Try using the paginate() method directly on the query builder.

For example:


public static function getroundsplayer($userid)
{
    return Playersround::where('userref_id', $userid)
        ->select('playersrounds.*', 'tees.name as teename', 'golfclubs.name as golfclubname', 'courcegolfclubs.courcename', 'startlists.*')
        ->join('startlists', 'startlists.id', '=', 'playersrounds.startlist_id')
        ->join('tees', 'tees.id', '=', 'playersrounds.teeref_id')
        ->join('golfclubs', 'golfclubs.id', '=', 'playersrounds.golf_id')
        ->join('courcegolfclubs', 'courcegolfclubs.id', '=', 'playersrounds.sloyferef_id')
        ->paginate(2);
}
2 likes

Please or to participate in this conversation.