christopher's avatar

Pagination

In my Controller i have

 $news = News::paginate(15);
 return View::make('news.index', compact('news'));

This is working, i get only 15 results. ?page=3 etc. is also working.

But if i want to display the pagination links on the bottom i get an error

In my View i have

{{ $news->links() }}

The error i`m getting is

Call to undefined method Illuminate\Database\Query\Builder::links() (View: /home/vagrant/code/news/app/views/news/index.blade.php)

0 likes
5 replies
RayRutjes's avatar

Maybe you are overwriting your $news variable somewhere else ?

ellenbrook's avatar

@rem that was my thought, most likely a @foreach($news as $news)

@hostianer, can you post the solution so others with the same problem can use your answer if it works for them?

1 like

Please or to participate in this conversation.