@php use App\Services\NavigationMenuService; use BladeUI\Icons\Exceptions\SvgNotFound; use BladeUI\Icons\Factory as BladeIconFactory; use Illuminate\Support\Facades\Auth; use Filament\Facades\Filament; // Try Filament auth first, then fall back to default auth. $user = null; try { $user = Filament::auth()->user(); } catch (\Exception $e) { $user = Auth::user(); } // Let NavigationMenuService handle user retrieval - it will try both Filament and standard Auth // This ensures consistent behavior and proper fallback handling $menu = NavigationMenuService::getMenu($user); // Get full path - isActive() will normalize it $currentPath = request()->path(); $expandedLogo = config('app.logo') ?: asset('images/sms.png'); $collapsedLogo = config('app.fab_logo') ?: asset('images/fav.png'); $sidebarGlobalSearchShortcuts = [ [ 'title' => 'Create Package', 'subtitle' => 'Core -> Packages -> Create Package', 'href' => '/admin/packages/create-package', 'keywords' => 'create package add package new package pricing plan subscription package', ], [ 'title' => 'Create Product', 'subtitle' => 'Core -> Products -> Create Product', 'href' => '/admin/products/create-product', 'keywords' => 'create product add product new product plan sku catalog item', ], [ 'title' => 'Coupons/Vouchers', 'subtitle' => 'Operations -> Back Office -> Coupons/Vouchers', 'href' => \App\Filament\Resources\BackOfficeAdminResource::getUrl('index') . '?tab=coupons', 'keywords' => 'coupon coupons coupan coupun voucher vouchers vaoucher promo discount campaign code', ], [ 'title' => 'Create Coupon', 'subtitle' => 'Operations -> Back Office -> Create Coupon', 'href' => \App\Filament\Resources\BackOfficeAdminResource::getUrl('create-coupon') . '?tab=coupons', 'keywords' => 'create coupon add coupon new coupon coupan coupun voucher vouchers vaoucher', ], [ 'title' => 'Create Email Template', 'subtitle' => 'Operations -> Back Office -> Create Email Template', 'href' => \App\Filament\Resources\BackOfficeAdminResource::getUrl('create-email-template') . '?tab=email', 'keywords' => 'create email template add email template mail campaign template', ], [ 'title' => 'Create SMS Template', 'subtitle' => 'Operations -> Back Office -> Create SMS Template', 'href' => \App\Filament\Resources\BackOfficeAdminResource::getUrl('create-sms-template') . '?tab=sms', 'keywords' => 'create sms template add sms template message campaign template', ], [ 'title' => 'B2B Partner', 'subtitle' => 'Operations -> B2B Partner', 'href' => '/admin/b2b-partner-operations', 'keywords' => 'b2b partner operations onboarding partner setup api contracts reconciliation transactions decisions', ], ]; $b2bPartnerOperationsPageClass = \App\Filament\Pages\Operations\B2BPartnerOperations::class; $b2bPartnerOperationsVisible = class_exists($b2bPartnerOperationsPageClass) && (!method_exists($b2bPartnerOperationsPageClass, 'canAccess') || $b2bPartnerOperationsPageClass::canAccess()); $b2bPartnerOperationsItem = $b2bPartnerOperationsVisible ? [ 'label' => 'B2B Partner', 'path' => '/admin/b2b-partner-operations', 'icon' => 'heroicon-o-building-office-2', ] : null; $extendOperationsChildren = static function (string $groupKey, array $children) use ($b2bPartnerOperationsItem): array { if ($groupKey !== 'Operations' || $b2bPartnerOperationsItem === null) { return $children; } foreach ($children as $label => $item) { $existingPath = strtolower(trim((string) ($item['path'] ?? ''))); if ( strcasecmp((string) $label, (string) $b2bPartnerOperationsItem['label']) === 0 || $existingPath === strtolower($b2bPartnerOperationsItem['path']) ) { return $children; } } $positionedChildren = []; $inserted = false; foreach ($children as $label => $item) { $positionedChildren[$label] = $item; if (strcasecmp((string) $label, 'Support Desk') === 0) { $positionedChildren[$b2bPartnerOperationsItem['label']] = [ 'path' => $b2bPartnerOperationsItem['path'], 'icon' => $b2bPartnerOperationsItem['icon'], ]; $inserted = true; } } if (!$inserted) { $positionedChildren[$b2bPartnerOperationsItem['label']] = [ 'path' => $b2bPartnerOperationsItem['path'], 'icon' => $b2bPartnerOperationsItem['icon'], ]; } return $positionedChildren; }; $canRenderBladeIcon = static function ($icon): bool { static $iconRenderability = []; if (!is_string($icon)) { return false; } $icon = trim($icon); if ($icon === '') { return false; } // Sidebar menu currently stores Heroicon aliases. Any unknown aliases // (for example "heroicon-o-triangle") should gracefully fallback. if (!\Illuminate\Support\Str::startsWith($icon, ['heroicon-'])) { return false; } if (array_key_exists($icon, $iconRenderability)) { return $iconRenderability[$icon]; } try { app(BladeIconFactory::class)->svg($icon); $iconRenderability[$icon] = true; } catch (SvgNotFound|\Throwable $e) { $iconRenderability[$icon] = false; } return $iconRenderability[$icon]; }; @endphp