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

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -