According to the documentation of Laravel 5.3 you can customize the view as follows:
Running the command of artisan
to transport the view
pagination standard for resources/views/vendor/pagination
:
php artisan vendor:publish --tag=laravel-pagination
From there, just edit the content HTML
of your default.blade.php
, which corresponds to default paging.
Also according to the documentation, you can customize the own functionalities of view
using the following methods:
$results->count()
$results->currentPage()
$results->firstItem()
$results->hasMorePages()
$results->lastItem()
$results->lastPage() (Not available when using simplePaginate)
$results->nextPageUrl()
$results->perPage()
$results->previousPageUrl()
$results->total() (Not available when using simplePaginate)
$results->url($page)
- Note that in the case of your question, using
simplePaginate()
, some methods are not available!
For paging on Laravel 5.2 and earlier
It is enough that instead of using the method render()
, do as follows:
@include('paginacao.default', ['paginator' => $artigos]) //onde o primeiro parâmetro é o caminho da sua view
And customize it by creating your Blade, for example:
@if ($paginator->lastPage() > 1)
<ul class="pagination">
<li class="{{ ($paginator->currentPage() == 1) ? ' disabled' : '' }}">
<a href="{{ $paginator->url(1) }}">Previous</a>
</li>
@for ($i = 1; $i <= $paginator->lastPage(); $i++)
<li class="{{ ($paginator->currentPage() == $i) ? ' active' : '' }}">
<a href="{{ $paginator->url($i) }}">{{ $i }}</a>
</li>
@endfor
<li class="{{ ($paginator->currentPage() == $paginator->lastPage()) ? ' disabled' : '' }}">
<a href="{{ $paginator->url($paginator->currentPage()+1) }}" >Next</a>
</li>
</ul>
@endif
Where for this version the available methods are:
$results->count()
$results->currentPage()
$results->firstItem()
$results->hasMorePages()
$results->lastItem()
$results->lastPage() (Not available when using simplePaginate)
$results->nextPageUrl()
$results->perPage()
$results->previousPageUrl()
$results->total() (Not available when using simplePaginate)
$results->url($page)
Which version of Laravel?
– Kenny Rafael
Larave 5.0, 5.1, 5.2. I saw that Laravel 5.3 has a pretty cool scheme as already commented.
– Diego Souza
Yeah, Laravel’s already awesome, and 5.3’s even better...
– Kenny Rafael