ella-stinnes's avatar

Display Pagination Totals on Single Page of Results

I'm displaying the pagination links as follows in my blade file: {{ $data->links() }}

This is displaying the pagination links and provides an overview on the total number of records:

Showing 1 to 10 of 18 results

I have an issue that when I run a search and the total number of records can fit to a single page, both the pagination links and totals disappear.

I understand why the pagination links disappear, but the totals are still useful and prevents the user from having to manually count the records on the page. Is there a helper I can use to still display the totals?

Showing 1 to 8 of 8 results

0 likes
4 replies
Pippo's avatar

You can execute php artisan vendor:publish --tag=laravel-pagination and customize the views in resources/views/vendor/pagination

ella-stinnes's avatar

@Pippo Thank you - I'm guessing this is the only option?

I'm surprised this is the default behaviour of the framework, I'm not sure why the user does not want to know how many records are returned when there's only 1 page.

ella-stinnes's avatar

@jlrdw Thank you. As someone new to Laravel, I just find the default behaviour odd and wasn't sure if I was missing something, because the count is useful for the end user regardless of the number of pages. I'll look at the links you've sent - thanks.

Please or to participate in this conversation.