Pagination in relation to Laravel

0

Is there a way to do pagination in Laravel in hasMany() method for relationships between models in Laravel?

    
asked by anonymous 23.10.2017 / 12:33

1 answer

0

Model user:

public function sites() {
    return $this->hasMany(Sites::class, 'user_id', 'id');
}

Model Sites:

public function user() {
    return $this->belongsTo(User::class,'user_id','id');
}

Controller:

User::find(122)->sites

Source: link

    
23.10.2017 / 12:46