Hướng dẫn custom css phân trang trong laravel tạo views/pagination/default.blade.php để css theo tuỳ ý

Step 1: tạo views/pagination/default.blade.php để css theo tuỳ ý,

@if ($paginator->hasPages())
<ul class="pagination pagination-blog justify-content-center">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled"><a class="page-link">&laquo;</a></li>
@else
<li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li>
@endif

{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="page-item disabled"><a class="page-link">{{ $element }}</a></li>
@endif

{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="page-item active"><a class="page-link">{{ $page }}</a></li>
@else
<li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach

{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li>
@else
<li class="page-item disabled"><a class="page-link">&raquo;</a></li>
@endif
</ul>
@endif

Step 2: Load pagination

<nav aria-label="Page navigation example">
{{ $items->appends(request()->input())->links('pagination.default') }}
</nav>
Kết quả