I'm using paginate for my pagination and I want to add custom markup for the $items->links()
in Blade like this:
<div class="pagination-wrapper">
{{ $items->links() }}
</div>
How do I check if the pagination links will be shown so that I won't print out an empty pagination-wrapper?
On Laravel 5 or above there is even better and Laravel native way to check if pagination links will be shown in laravel blade.
@if ($items->hasPages())
<div class="pagination-wrapper">
{{ $items->links() }}
</div>
@endif
From Laravel API documentation
+----------------------+-------------------------------------------------------------------+
| Method | Description |
+----------------------+-------------------------------------------------------------------+
| $results->hasPages() | Determine if there are enough items to split into multiple pages. |
+----------------------+-------------------------------------------------------------------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With