@if ($paginator->hasPages())
{{-- prev button --}} @if ($paginator->onFirstPage()) @else
@endif {{-- end prev button --}} {{-- Pages --}} @foreach ($elements as $element) {{-- @if (is_string($element)) @endif --}} @if (is_array($element)) @php $currentPage = $paginator->currentPage(); $lastPage = $paginator->lastPage(); $pageNumbers = []; for ($i = 1; $i <= $lastPage; $i++) { if ($i == 1 || $i == $lastPage || $i == $currentPage || ($i >= $currentPage - 1 && $i <= $currentPage + 1)) { $pageNumbers[] = $i; } } @endphp @foreach ($element as $page => $url) @if ($page == $currentPage) @elseif ($page == 1 && !in_array(2, $pageNumbers)) @if (!in_array(2, $pageNumbers) && $currentPage > 3) @endif @elseif ($page == $lastPage && !in_array($lastPage - 1, $pageNumbers)) @if ($lastPage - $currentPage > 2) @endif @elseif (in_array($page, $pageNumbers)) @if ($page - $currentPage > 2) @endif @endif @endforeach @endif @endforeach {{--end pages--}} {{-- next button --}} @if ($paginator->hasMorePages())
@else @endif {{--end next btn --}}
@endif