Limit amount of links shown with Laravel pagination

前端 未结 11 2218
一个人的身影
一个人的身影 2020-12-14 02:10

Any easy way to limit how many links are shown with Laravels pagination?

Currently it shows 13 links at most (Prev, 1 2 3 4 5 7 8 .. 78 79 next)

This however

11条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 02:24

    Now Laravel 5.7 has a new pagination method to customize the number of links on each side of the paginator. Thanks to the new method you no longer need a custom pagination view in some cases. Here’s the API you can use to define the link count on each side of the current page:

    User::paginate(10)->onEachSide(2);
    

    write that code on your controller.

    you can see more detail at https://laravel-news.com/laravel-5-7-pagination-link-customizations

提交回复
热议问题