To customizing the pagination view, run below command in console
php artisan vendor:publish --tag=laravel-pagination
in /resources/views/vendor/pagination/bootstrap-4.blade.php add bellow code.
<ul class="pagination">
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.first')">
<span class="page-link" aria-hidden="true">«</span>
</li>
@else
<li class="page-item">
<a class="page-link" href="{{ \Request::url() }}" rel="prev" aria-label="@lang('pagination.first')">«</a>
</li>
@endif
...
@if ($paginator->hasMorePages())
<li class="page-item">
<a class="page-link" href="{{ \Request::url().'?page='.$paginator->lastPage() }}" rel="last" aria-label="@lang('pagination.last')">»</a>
</li>
@else
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.last')">
<span class="page-link" aria-hidden="true">»</span>
</li>
@endif
</ul>
<?php
class MyPresenter extends Illuminate\Pagination\BootstrapPresenter {
public function render()
{
if ($this->currentPage == 1) {
$content = $this->getPageRange(1, $this->currentPage + 2);
}
else if ($this->currentPage >= $this->lastPage) {
$content = $this->getPageRange($this->currentPage - 2, $this->lastPage);
}
else {
$content = $this->getPageRange($this->currentPage - 1, $this->currentPage + 1);
}
return $this->getFirst().$this->getPrevious('‹').$content.$this->getNext('›').$this->getLast();
}
public function getFirst($text = '«')
{
if ($this->currentPage <= 1)
{
return $this->getDisabledTextWrapper($text);
}
else
{
$url = $this->paginator->getUrl(1);
return $this->getPageLinkWrapper($url, $text);
}
}
public function getLast($text = '»')
{
if ($this->currentPage >= $this->lastPage)
{
return $this->getDisabledTextWrapper($text);
}
else
{
$url = $this->paginator->getUrl($this->lastPage);
return $this->getPageLinkWrapper($url, $text);
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.