php - Laravel 5 - paginate Eloquent collection -


model:

class category extends model {     public function trainings()     {         return $this->hasmany('app\training');     } } 

controller:

return view('category', [     'trainings' => category::find(1)->trainings->paginate(10) ]); 

i'm getting call undefined method illuminate\database\eloquent\collection::paginate() error.

how can paginate eloquent collection in laravel 5?

you have call trainings method:

category::find(1)->trainings()->paginate(10) //                          ^^ 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -