@if ($paginator->hasPages())
@php
$currentPage = $paginator->currentPage();
$lastPage = $paginator->lastPage();
$maxPages = 8;
// Calculate start and end page numbers
$halfMax = floor($maxPages / 2);
$start = max(1, $currentPage - $halfMax);
$end = min($lastPage, $start + $maxPages - 1);
// Adjust start if we're near the end
if ($end - $start + 1 < $maxPages) {
$start = max(1, $end - $maxPages + 1);
}
@endphp
@endif