{{-- The BCP sidebar. The navigation is declared once, as data, and rendered from that. It used to be twenty hand-written anchors each carrying its own copy of the same conditional class string, which is why the accent colour had ended up in 365 places. One array here means the search index, the collapsed-mode flyouts and the markup itself cannot drift apart. Labels, groupings, icons and route matching are carried over exactly as they were. Nothing has been renamed, regrouped or dropped. --}} @php //Icon paths lifted verbatim from the previous sidebar, so the panel looks //like itself. $icons = [ 'home' => 'M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6', 'building' => 'M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4', 'cube' => 'M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4', 'clipboard'=> 'M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2', 'card' => 'M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z', 'receipt' => 'M9 14l6-6m-5.5.5h.01m4.99 5h.01M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16l4-2 4 2 4-2 4 2z', 'shield' => 'M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z', 'key' => 'M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 0121 9z', 'users' => 'M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z', 'chat' => 'M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z', 'warning' => 'M12 9v3m0 4h.01M5.07 19H18.93a2 2 0 001.74-3L13.74 4a2 2 0 00-3.48 0L3.33 16a2 2 0 001.74 3z', 'doc' => 'M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01', 'clock' => 'M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z', ]; //The navigation, exactly as it stood: same labels, same order, same groups. $navGroups = [ [ 'label' => 'Multi-Tenant Core (Phase 2)', 'items' => [ ['label' => 'Tenants Directory', 'url' => route('admin.tenants.index'), 'active' => request()->is('admin/tenants*'), 'icon' => 'building'], ], ], [ 'label' => 'Subscriptions & Billing (Phase 3)', 'items' => [ ['label' => 'Products Catalog', 'url' => route('admin.products.index'), 'active' => request()->is('admin/products*'), 'icon' => 'cube'], ['label' => 'Plan Tiers', 'url' => route('admin.plans.index'), 'active' => request()->is('admin/plans*'), 'icon' => 'clipboard'], ['label' => 'Subscriptions', 'url' => route('admin.subscriptions.index'), 'active' => request()->is('admin/subscriptions*'), 'icon' => 'card'], ['label' => 'Invoices & Billing', 'url' => route('admin.invoices.index'), 'active' => request()->is('admin/invoices*'), 'icon' => 'receipt'], ['label' => 'Payment Links', 'url' => route('admin.payment-links.index'), 'active' => request()->is('admin/payment-links*'), 'icon' => 'card'], ['label' => 'Payments & Reconciliation', 'url' => route('admin.payments.index'), 'active' => request()->is('admin/payments*'), 'icon' => 'receipt'], ], ], [ //Every product BCP bills for, listed from the Product table rather //than written out here. POS, BinduHost and BMart appear because //they exist; BinduAI and Bindu Drive appear the day somebody adds //them through the Products screen. A menu that reads the same //table the screens do cannot fall out of step with them. 'label' => 'SaaS Products', 'items' => collect($saasProducts ?? [])->map(fn ($saasProduct) => [ 'label' => $saasProduct->name, 'url' => route('admin.saas.overview', $saasProduct->slug), 'active' => request()->is('admin/saas/'.$saasProduct->slug) || request()->is('admin/saas/'.$saasProduct->slug.'/*'), 'icon' => 'cube', //How many plans it sells, so the menu says which products are //actually on sale without opening any of them. 'badge' => ($saasProduct->plans_count ?? 0) > 0 ? ['text' => (string) $saasProduct->plans_count, 'tone' => 'slate'] : null, ])->all(), ], [ 'label' => 'Licensing Engine & API (Phase 4)', 'items' => [ ['label' => 'Licenses Vault', 'url' => route('admin.licenses.index'), 'active' => request()->is('admin/licenses*'), 'icon' => 'shield'], ['label' => 'API Bearer Tokens', 'url' => route('admin.tokens.index'), 'active' => request()->is('admin/tokens*'), 'icon' => 'key'], ], ], [ 'label' => 'Customer Hub (Phase 5)', 'items' => [ ['label' => 'Customer 360° Directory', 'url' => route('admin.customers.index'), 'active' => request()->is('admin/customers*'), 'icon' => 'users'], ], ], [ 'label' => 'Support Desk (Phase 6)', 'items' => [ ['label' => 'Unified Inbox', 'url' => route('admin.tickets.index'), 'active' => request()->is('admin/tickets*'), 'icon' => 'chat'], ['label' => 'Brands', 'url' => route('admin.brands.index'), 'active' => request()->is('admin/brands') || request()->is('admin/brands/create') || request()->is('admin/brands/*/edit'), 'icon' => 'building'], ['label' => 'Brand Staff Access', 'url' => route('admin.brands.staff'), 'active' => request()->is('admin/brands/staff'), 'icon' => 'users'], ['label' => 'Support Staff', 'url' => route('admin.staff.index'), 'active' => request()->is('admin/staff*'), 'icon' => 'users'], ['label' => 'Audit Logs', 'url' => route('admin.audit-logs.index'), 'active' => request()->is('admin/audit-logs*'), 'icon' => 'clipboard'], ], ], [ 'label' => 'Security & Alerts (Phase 7)', 'items' => [ //Also reachable from the bell in the top bar, but that bell //is hidden on a phone, so this is the way in on one. The //badge is the same unread count the bell carries. ['label' => 'Notifications', 'url' => route('admin.notifications.index'), 'active' => request()->is('admin/notifications*'), 'icon' => 'warning', 'badge' => ($unreadNotifications ?? 0) > 0 ? ['text' => (string) $unreadNotifications, 'tone' => 'amber'] : null], ['label' => 'Audit & Security', 'url' => route('admin.security-events.index'), 'active' => request()->is('admin/security*'), 'icon' => 'warning'], //Queued work that failed. Badged because the failure is //silent by nature: the customer who was never emailed does //not appear anywhere else in the panel. ['label' => 'Background Work', 'url' => route('admin.failed-work.index'), 'active' => request()->is('admin/failed-work*'), 'icon' => 'clock', 'badge' => ($failedQueueWork ?? 0) > 0 ? ['text' => (string) $failedQueueWork, 'tone' => 'amber'] : null], ], ], [ 'label' => 'SMS Control', 'items' => [ ['label' => 'SMS Dashboard', 'url' => route('admin.sms.dashboard'), 'active' => request()->is('admin/sms'), 'icon' => 'chat'], ['label' => 'Purchase Orders', 'url' => route('admin.sms.orders.index'), 'active' => request()->is('admin/sms/orders*'), 'icon' => 'doc', 'badge' => ($pendingSmsOrders ?? 0) > 0 ? ['text' => (string) $pendingSmsOrders, 'tone' => 'amber'] : null], ['label' => 'SMS Balance', 'url' => route('admin.sms.balances.index'), 'active' => request()->is('admin/sms/balances*'), 'icon' => 'card'], ['label' => 'SMS History', 'url' => route('admin.sms.history.index'), 'active' => request()->is('admin/sms/history*'), 'icon' => 'clock'], ['label' => 'SMS Packages', 'url' => route('admin.sms.packages.index'), 'active' => request()->is('admin/sms/packages*'), 'icon' => 'cube'], ], ], //Your own account, not the product. A super admin had no menu route to //either of these -- the support-only sidebar below carried them and //this one did not, so the people most worth protecting were the ones //who could not find the page that protects them. [ 'label' => 'Your Account', 'items' => [ ['label' => 'Two-Step Verification', 'url' => route('admin.account.two-factor.edit'), 'active' => request()->is('admin/account/two-factor*'), 'icon' => 'shield'], ['label' => 'Change Password', 'url' => route('admin.account.password.edit'), 'active' => request()->is('admin/account/password*'), 'icon' => 'users'], ], ], [ 'label' => 'Future Core Modules', 'items' => [ ['label' => 'Licensing Engine', 'icon' => 'shield', 'muted' => true, 'badge' => ['text' => 'Phase 4', 'tone' => 'slate']], ['label' => 'Customer Hub (360°)', 'icon' => 'users', 'muted' => true, 'badge' => ['text' => 'Phase 5', 'tone' => 'slate']], ['label' => 'Unified Inbox', 'icon' => 'chat', 'muted' => true, 'badge' => ['text' => 'Phase 6', 'tone' => 'slate']], ], ], ]; //A brand support agent gets a sidebar of what they can actually open. //The superadmin navigation above is untouched and still the default; this //replaces it wholesale for support-only accounts rather than hiding //entries one by one, because a hidden link is still a link — the routes //themselves are what refuse them, and the menu should simply not lie //about what is available. if (auth()->check() && ! \Illuminate\Support\Facades\Gate::allows('access-admin')) { $navGroups = [ [ 'label' => null, 'items' => [ ['label' => 'Support Dashboard', 'url' => route('admin.support.dashboard'), 'active' => request()->is('admin/support*'), 'icon' => 'home'], //Reachable by every staff account, super admins included: it //only ever changes the password of whoever is signed in. ['label' => 'Change Password', 'url' => route('admin.account.password.edit'), 'active' => request()->is('admin/account/password*'), 'icon' => 'users'], ['label' => 'Two-Step Verification', 'url' => route('admin.account.two-factor.edit'), 'active' => request()->is('admin/account/two-factor*'), 'icon' => 'users'], ], ], [ 'label' => 'Support Desk', 'items' => [ ['label' => 'Support Tickets', 'url' => route('admin.tickets.index'), 'active' => request()->is('admin/tickets*'), 'icon' => 'chat'], ], ], ]; } //Give every group a stable key, work out which one holds the current page, //and build the index the JavaScript searches. Same data, one source. $navIndex = []; foreach ($navGroups as $i => $group) { $key = 'g' . $i; $navGroups[$i]['key'] = $key; $navGroups[$i]['hasActive'] = collect($group['items'])->contains(fn ($item) => ! empty($item['active'])); //A group of one needs no flyout when collapsed — its single item can //just stay on screen as an icon. $navGroups[$i]['multi'] = count($group['items']) > 1; $navIndex[] = [ 'key' => $key, 'label' => $group['label'], 'items' => collect($group['items'])->map(fn ($item) => [ 'label' => $item['label'], 'url' => $item['url'] ?? null, 'active' => ! empty($item['active']), 'muted' => ! empty($item['muted']), ])->values()->all(), ]; } $badgeTones = [ 'emerald' => 'bg-emerald-500/20 text-emerald-400', 'amber' => 'bg-amber-500/20 text-amber-400', 'slate' => 'bg-slate-800 text-slate-400', ]; @endphp {{-- Tooltip and flyout live outside the scrolling nav so they are not clipped at the sidebar edge, which is precisely where they need to appear. Visibility is a class, not x-show. Both are display:none in CSS until Alpine adds .is-visible, so an un-booted or broken component leaves them invisible rather than parked at top-left over the header. --}}