How to change the number of links in the pagination block? (Laravel 8)

Viewed 26

I use Laravel Framework 8 (8.83.23). Please help me understand how to set a limit on the number of links.

I have this (custom template in views/vendor/pagination):

enter image description here

And want to get this:

enter image description here

Already tried this:

/** In controller */
public function index()
{
    return view('pages.products.index')
        ->with(
            'products',
            Product::latest()
                ->paginate(12)
                ->onEachSide(2)
        );
}

And this (without using onEachSide in controller):

/** In blade */
<div class="row py-5">
    <div class="col-auto mx-auto">
        {{ $products->onEachSide(2)->links() }}
    </div>
</div>
0 Answers
Related