@if ($paginator->hasPages()) @php $current = $paginator->currentPage(); $last = $paginator->lastPage(); // 🔥 ambil onEachSide dari paginator $onEachSide = method_exists($paginator, 'onEachSide') ? $paginator->onEachSide : 2; $start = max(1, $current - $onEachSide); $end = min($last, $current + $onEachSide); @endphp
{{-- PREVIOUS --}} @if ($paginator->onFirstPage()) @else @endif {{-- FIRST PAGE --}} @if ($start > 1) 1 @if ($start > 2) ... @endif @endif {{-- MIDDLE PAGES --}} @for ($i = $start; $i <= $end; $i++) @if ($i == $current) {{ $i }} @else {{ $i }} @endif @endfor {{-- LAST PAGE --}} @if ($end < $last) @if ($end < $last - 1) ... @endif {{ $last }} @endif {{-- NEXT --}} @if ($paginator->hasMorePages()) @else @endif
@endif