Skip to content

Instantly share code, notes, and snippets.

@flexchar
Created September 24, 2018 10:25
Show Gist options
  • Select an option

  • Save flexchar/cd4e23a75b5a23ed8d6010c05c715f96 to your computer and use it in GitHub Desktop.

Select an option

Save flexchar/cd4e23a75b5a23ed8d6010c05c715f96 to your computer and use it in GitHub Desktop.
Rich Laravel Bulma Paginator with Localization
<?php
return [
/*
|--------------------------------------------------------------------------
| Pagination Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used by the paginator library to build
| the simple pagination links. You are free to change them to anything
| you want to customize your views to better match your application.
|
*/
'previous' => 'Previous',
'next' => 'Next',
'goto' => 'Goto page :number',
];
@if ($paginator->hasPages())
<nav class="pagination is-centered is-rounded" role="navigation" aria-label="pagination">
@if ($paginator->onFirstPage())
<a class="pagination-previous" disabled>{{ trans('pagination.previous') }}</a>
@else
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="pagination-previous">{{ trans('pagination.previous') }}</a>
@endif
@if ($paginator->hasMorePages())
<a class="pagination-next" href="{{ $paginator->nextPageUrl() }}" rel="next">{{ trans('pagination.next') }}</a>
@else
<a class="pagination-next" disabled>{{ trans('pagination.next') }}</a>
@endif
<ul class="pagination-list">
@if ($paginator->firstItem() && !$paginator->onFirstPage() && $paginator->currentPage()-1 !== 1)
<li><a class="pagination-link" href="{{ $paginator->url( 1 ) }}" aria-label="{{ trans('pagination.goto', ['number' => 1]) }}">1</a></li>
@if( $paginator->currentPage()-2 !== 1 )
<li><span class="pagination-ellipsis">&hellip;</span></li>
@endif
@endif
@if ($paginator->previousPageUrl())
<li><a class="pagination-link" href="{{ $paginator->previousPageUrl() }}" aria-label="{{ trans('pagination.goto', ['number' => $paginator->currentPage()-1]) }}">{{ $paginator->currentPage()-1 }}</a></li>
@endif
@if ($paginator->currentPage())
<li><a class="pagination-link is-current">{{ $paginator->currentPage() }}</a></li>
@else
<li><a class="pagination-link is-current" aria-label="{{ trans('pagination.goto', ['number' => $paginator->currentPage()]) }}" aria-current="page">46</a></li>
@endif
@if ($paginator->hasMorePages())
<li><a class="pagination-link" href="{{ $paginator->nextPageUrl() }}" aria-label="{{ trans('pagination.goto', ['number' => $paginator->currentPage()+1]) }}">{{ $paginator->currentPage()+1 }}</a></li>
@if( $paginator->currentPage()+3 <= $paginator->lastPage() )
<li><span class="pagination-ellipsis">&hellip;</span></li>
@endif
@if( $paginator->currentPage()+1 !== $paginator->lastPage() )
<li><a class="pagination-link" href="{{ $paginator->url( $paginator->lastPage() ) }}" aria-label="{{ trans('pagination.goto', ['number' => $paginator->lastPage()]) }}">{{ $paginator->lastPage() }}</a></li>
@endif
@endif
</ul>
</nav>
@endif
@flexchar

Copy link
Copy Markdown
Author

Use in your views with {{ $dataPassedFromPaginatedModel->links('layout.pagination') }}.

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