In Laravel 8 pagination how to show less number of pages and also how to add “First Page” and “Last Page”
Now in Laravel when we have more data, it will show the pagination like this:
But I want my pagination to be like the images given below:
Or
Advertisement
Answer
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>