here is the image of pagination, the numbers of pagination's page is too many so how can i show some of them and disable the rest the code is here $saleInvoices = SaleInvoice::paginate(10);
-
2Can you show us the code that makes up the pagination? – Ben Jul 18 '16 at 11:17
-
just $saleInvoices = SaleInvoice::paginate(10); – Shadow Jul 18 '16 at 11:17
-
2Possible duplicate of [Limit amount of links shown with Laravel pagination](http://stackoverflow.com/questions/27655992/limit-amount-of-links-shown-with-laravel-pagination) – madalinivascu Jul 18 '16 at 11:19
-
solution is not working – Shadow Jul 18 '16 at 11:43
2 Answers
For that you have to create custom presenter. Here is article how to create custom presenter, Click Here.

- 1,976
- 2
- 13
- 28
It really depends on how you are establishing the pagination (always worth adding your code to your question), but you can limit the number pages based your query results a couple of ways.
If you're simply paginating your Eloquent results:
$perPage = 10;
$results = App\User::paginate($perPage);
Let's say you have 100 users in your database, this example is going to return your users paginated into 10 pages ie. 100 users at 10 users per page. If you only wanted a maximum of 5 pages in your pagination you could either:
1. Limit the users loaded:
$perPage = 10;
$results = App\User::take(50)->paginate($perPage);
2. Divide all the users between a maximum of 5 pages:
$totalUsers = App\User::count();
$perPage = ($totalUsers > 50)? ceil($totalUsers/5) : 10;
$results = App\User::paginate($perPage);
Here we get the user count and check if it's greater than 50 (5 pages x 10 users per page). If yes we divide the users equally between the maximum 5 pages. If no we stick to a max of 10 users per page.
I hope that's helpful. If it's not what you're after you'll to clarify your question :)

- 5,224
- 1
- 24
- 26
-
I want to hide the number of pages in pagination to make pagination links more soft but your solution talks about minimizing the number pagination's links by manipulating with number of records per page. – Shadow Jul 18 '16 at 12:59
-
Ok so to clarify if you have 10 pages you want to show 1|2|...|9|10 for example? – Steve O Jul 19 '16 at 16:20
-
-
Ah ok, in that case a custom presenter is indeed what you want, so the tutorial posted in Hiren's answer is the one you need :) – Steve O Jul 20 '16 at 08:30