Skip to content

Instantly share code, notes, and snippets.

@manderton
Created October 5, 2019 14:19
Show Gist options
  • Save manderton/2b0750e32ebb0615c6e6cabd0a2d3fda to your computer and use it in GitHub Desktop.
Save manderton/2b0750e32ebb0615c6e6cabd0a2d3fda to your computer and use it in GitHub Desktop.
Laravel + Bulma Pagination
@if ($paginator->hasPages())
<nav class="pagination is-rounded">
<ul class="pagination-list">
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="disabled" aria-disabled="true"><span>{{ $element }}</span></li>
@endif
{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="pagination-link is-current" aria-current="page"><span>{{ $page }}</span></li>
@else
<li><a class="pagination-link" href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach
</ul>
<a class="pagination-previous{{ ($paginator->onFirstPage()) ? " disabled" : ""}}" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>
<a href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')" class="pagination-next{{ (!$paginator->hasMorePages()) ? " disabled" : ""}}">&rsaquo;</a>
</nav>
@endif
@manderton
Copy link
Author

See this page:

https://laravel.com/docs/6.x/pagination#customizing-the-pagination-view

... have to change the default pagination view in AppServiceProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment