@php function is_active($pattern, $strict = false) { $url = url()->current(); if ($strict) { return $url === $pattern ? 'active' : ''; } // For pattern with hash like home#about [$base, $hash] = array_pad(explode('#', $pattern, 2), 2, ''); if ($hash) { // Compare current URL and current hash (fragment) return (stripos($url, $base) === 0 && request()->getRequestUri() === parse_url($pattern, PHP_URL_PATH) . '#' . $hash) ? 'active' : ''; } return (stripos($url, $pattern) === 0) ? 'active' : ''; } @endphp
@push('scripts') @endpush