Is there a way to do pagination in Laravel in hasMany()
method for relationships between models in Laravel?
Is there a way to do pagination in Laravel in hasMany()
method for relationships between models in Laravel?
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