Last active
September 10, 2020 20:33
-
-
Save tompec/cd4051aafebd3c150c72771902746821 to your computer and use it in GitHub Desktop.
Bulma blade template for Laravel 5.4 pagination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if ($paginator->hasPages()) | |
<nav class="pagination is-centered"> | |
@if ($paginator->onFirstPage()) | |
<a class="pagination-previous" disabled>Previous</a> | |
@else | |
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="pagination-previous">Previous</a> | |
@endif | |
@if ($paginator->hasMorePages()) | |
<a class="pagination-next" href="{{ $paginator->nextPageUrl() }}" rel="next">Next</a> | |
@else | |
<a class="pagination-next" disabled>Next page</a> | |
@endif | |
<ul class="pagination-list"> | |
{{-- Pagination Elements --}} | |
@foreach ($elements as $element) | |
{{-- "Three Dots" Separator --}} | |
@if (is_string($element)) | |
<li><span class="pagination-ellipsis"><span>{{ $element }}</span></span></li> | |
@endif | |
{{-- Array Of Links --}} | |
@if (is_array($element)) | |
@foreach ($element as $page => $url) | |
@if ($page == $paginator->currentPage()) | |
<li><a class="pagination-link is-current">{{ $page }}</a></li> | |
@else | |
<li><a href="{{ $url }}" class="pagination-link">{{ $page }}</a></li> | |
@endif | |
@endforeach | |
@endif | |
@endforeach | |
</ul> | |
</nav> | |
@endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really useful, thx allot!
In my case I needed a little more flexibility, and also needed some translation. Luckily the
links()
method accepts a data array, so I have added the following code to<nav class=”pagination”>
element:<nav class="pagination @isset($bulmaClasses) {{ $bulmaClasses }} @else is-centered @endisset">
And to the anchor tags:
and:
So now I can include it like this:
$data->links('vendor.pagination.bulma', ['bulmaClasses' => 'is-small is-centered', 'next' => '/*text for next button*/', 'previous' => '/*text for previous button*/'])