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
Post a Comment