98 lines
5.8 KiB
PHP
98 lines
5.8 KiB
PHP
<nav class="d-flex justify-content-between align-items-center my-3">
|
|
{{-- SELECT ITEMS PER PAGE --}}
|
|
<div class="dropup-center dropup d-flex justify-content-center align-items-center input-group w-fit">
|
|
<span class="btn-md input-group-text" data-bs-toggle="tooltip" data-bs-placement="top"
|
|
title="{{ __('crud.pagination.paginate_list') }}">
|
|
<i class="fa-solid fa-list-ul"></i>
|
|
</span>
|
|
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" type="button" aria-expanded="false">
|
|
{{ Cache::get('pagination.' .Str::slug(request()->route()->getName())) }}
|
|
</button>
|
|
<ul class="dropdown-menu">
|
|
@foreach (\App\Enums\Pagination\ItemsPerPaginationEnum::toArray() as $itemsPerPaginationEnum)
|
|
<li>
|
|
<a class="dropdown-item text-center"
|
|
href="{{ request()->fullUrlWithQuery(['pagination' => $itemsPerPaginationEnum->value]) }}">
|
|
{{ $itemsPerPaginationEnum->value }}
|
|
</a>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
@if ($paginator->hasPages())
|
|
{{-- PAGINATION --}}
|
|
<div class="d-flex justify-content-end align-items-center">
|
|
<ul class="pagination m-0">
|
|
{{-- PREVIOUS PAGE --}}
|
|
<li class="page-item @if ($paginator->onFirstPage()) disabled @endif">
|
|
<a class="page-link d-flex align-items-center h-100" data-bs-toggle="tooltip" data-bs-placement="top"
|
|
title="{{ __('crud.pagination.previous') }}" aria-label="@lang('crud.pagination.previous')"
|
|
@if (!$paginator->onFirstPage()) href="{{ $paginator->previousPageUrl() }}" @endif rel="prev"
|
|
@if ($paginator->onFirstPage()) aria-hidden="true" @endif>
|
|
<i class="fa-solid fa-chevron-left fa-2xs mt-1"></i>
|
|
</a>
|
|
</li>
|
|
{{-- FIRST PAGE --}}
|
|
@if ($paginator->currentPage() > 3)
|
|
<li class="page-item" data-bs-toggle="tooltip" data-bs-placement="top"
|
|
title="{{ __('crud.pagination.specific_page', ['id' => 1]) }}">
|
|
<a class="page-link" href="{{ $paginator->url(1) }}">1</a>
|
|
</li>
|
|
@endif
|
|
{{-- HIDE PAGES TOO FAR --}}
|
|
@if ($paginator->currentPage() > 4)
|
|
<li class="page-item disabled"><span class="page-link">...</span></li>
|
|
@endif
|
|
{{-- SHOW ACTUAL PAGES + N-2/N+2 --}}
|
|
@foreach (range(1, $paginator->lastPage()) as $i)
|
|
@if ($i >= $paginator->currentPage() - 2 && $i <= $paginator->currentPage() + 2)
|
|
@if ($i == $paginator->currentPage())
|
|
<li class="page-item">
|
|
<div class="dropup-center dropup">
|
|
<button class="btn btn-primary dropdown-toggle rounded-0" data-bs-toggle="dropdown" type="button"
|
|
aria-expanded="false">
|
|
{{ $i }}
|
|
</button>
|
|
<ul class="dropdown-menu">
|
|
@for ($i = 1; $i <= $paginator->lastPage(); $i++)
|
|
<li>
|
|
<a class="dropdown-item text-center"
|
|
href="{{ request()->fullUrlWithQuery(['page' => $i]) }}">
|
|
{{ $i }}
|
|
</a>
|
|
</li>
|
|
@endfor
|
|
</ul>
|
|
</div>
|
|
</li>
|
|
@else
|
|
<li class="page-item" data-bs-toggle="tooltip" data-bs-placement="top"
|
|
title="{{ __('crud.pagination.specific_page', ['id' => $i]) }}">
|
|
<a class="page-link" href="{{ $paginator->url($i) }}">{{ $i }}</a>
|
|
</li>
|
|
@endif
|
|
@endif
|
|
@endforeach
|
|
{{-- HIDE PAGES TOO FAR --}}
|
|
@if ($paginator->currentPage() < $paginator->lastPage() - 3)
|
|
<li class="page-item disabled"><span class="page-link">...</span></li>
|
|
@endif
|
|
{{-- LAST PAGE --}}
|
|
@if ($paginator->currentPage() < $paginator->lastPage() - 2)
|
|
<li class="page-item" data-bs-toggle="tooltip" data-bs-placement="top"
|
|
title="{{ __('crud.pagination.specific_page', ['id' => $paginator->lastPage()]) }}">
|
|
<a class="page-link" href="{{ $paginator->url($paginator->lastPage()) }}">{{ $paginator->lastPage() }}</a>
|
|
</li>
|
|
@endif
|
|
{{-- NEXT PAGE --}}
|
|
<li class="page-item @if (!$paginator->hasMorePages()) disabled @endif">
|
|
<a class="page-link d-flex align-items-center h-100" data-bs-toggle="tooltip" data-bs-placement="top"
|
|
title="{{ __('crud.pagination.next') }}" aria-label="@lang('crud.pagination.next')"
|
|
@if ($paginator->hasMorePages()) href="{{ $paginator->nextPageUrl() }}" @endif rel="next"
|
|
@if (!$paginator->hasMorePages()) aria-hidden="true" @endif>
|
|
<i class="fa-solid fa-chevron-right fa-2xs mt-1"></i></a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
@endif
|
|
</nav>
|