Support the ongoing development of →
posted 5 years ago
Last updated 1 year ago.


First of all you should update your "query":

$pubs = \App\Pub::where('rsTown', 'Brighton')
               ->orderBy('id', 'desc')
               ->paginate(10); // the number of the items per page
return view('pubindex',compact('pubs'));

In the view you can generate the links of the pages:

{{ $pubs->links() }}

That is all. Laravel do the other stuffs. But the Laravel has a really good documentation about this:


Hi, Hopfully that's gonna work :

public function index()
     // All you need to make the pagination works, 
     // is to replace get() with paginate(10)
     $pubs=\App\Pub::where('rsTown', 'Brighton')
            ->orderBy('id', 'desc')
     return view('pubindex',compact('pubs'));

in the view: put

{{ $pubs->links() }}

Excellent! Thank you!

Where I was going wrong originally was, I was keeping in get();


You Welcome


Sign in to participate in this thread!

Full Stack Europe

Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.