@props(['active' => 'overview']) @php $supportOpen = $supportUnassigned = 0; try { $supportOpen = (int) \App\Models\SupportTicket::whereIn('status', ['open', 'in_progress', 'pending'])->count(); $supportUnassigned = (int) \App\Models\SupportTicket::whereNull('assigned_agent_id') ->whereIn('status', ['open', 'pending']) ->count(); } catch (\Throwable $e) { } // Live counts for the rest of the sidebar — every "static" 4 / 142 // / 18k / 1.2k pill was hard-coded prototype text. These now read // from the actual tables. Each is wrapped so a missing table / // schema mismatch never takes the sidebar down. $fmtCount = function (int $n): string { if ($n >= 1000000) { return number_format($n / 1000000, $n >= 10000000 ? 0 : 1) . 'M'; } if ($n >= 1000) { return number_format($n / 1000, $n >= 10000 ? 0 : 1) . 'k'; } return (string) $n; }; $usersCount = $rolesCount = $permsCount = $workspacesCount = $devicesCount = 0; $packagesCount = $creditPackagesCount = $couponsCount = $billingHistoryCount = $orderHistoryCount = $invoicesCount = 0; $supportTeamCount = $supportAgentsCount = $supportSlaCount = $supportCustomersCount = $supportPlaybooksCount = 0; $announcementsCount = $guidebookCount = 0; $contactUnread = 0; try { $contactUnread = (int) \App\Models\ContactMessage::where('is_read', false)->count(); } catch (\Throwable $e) { } try { $usersCount = (int) \App\Models\User::query()->count(); } catch (\Throwable $e) { } try { $devicesCount = (int) \App\Models\Device::query()->count(); } catch (\Throwable $e) { } try { $rolesCount = (int) \DB::table('roles')->count(); } catch (\Throwable $e) { } try { $permsCount = (int) \DB::table('permissions')->count(); } catch (\Throwable $e) { } try { $workspacesCount = (int) \App\Models\Workspace::query()->count(); } catch (\Throwable $e) { } try { $packagesCount = (int) \App\Models\Package::query()->count(); } catch (\Throwable $e) { } try { $creditPackagesCount = (int) \App\Models\CreditPackage::query()->count(); } catch (\Throwable $e) { } // Coupons badge = active coupons only — expired/disabled coupons // are noise on the sidebar. "active" means is_active + within // valid_from/valid_to window when those columns exist. try { $couponsCount = (int) \App\Models\Coupon::query() ->when(\Schema::hasColumn('coupons', 'is_active'), fn($q) => $q->where('is_active', true)) ->count(); } catch (\Throwable $e) { } try { $billingHistoryCount = (int) \DB::table('orders')->count(); } catch (\Throwable $e) { } try { $orderHistoryCount = (int) \DB::table('orders')->count(); } catch (\Throwable $e) { } try { $invoicesCount = (int) \DB::table('orders')->where('status', 'paid')->count(); } catch (\Throwable $e) { } // Support group children. Each lookup is independent so a missing // table on a fresh install just leaves that badge blank. try { $supportTeamCount = (int) \App\Models\SupportTicket::whereNull('assigned_agent_id') ->whereIn('status', ['open', 'pending', 'in_progress']) ->count(); } catch (\Throwable $e) { } try { $supportAgentsCount = (int) \App\Models\SupportAgent::where('is_active', true)->count(); } catch (\Throwable $e) { } // SLA badge = tickets with first_response/resolution SLA at risk // or already breached. Cheap heuristic: open tickets without a // first_response_at older than the workspace SLA window. Falls // back to all open tickets if the SLA column isn't there. try { $supportSlaCount = (int) \App\Models\SupportTicket::query() ->whereIn('status', ['open', 'pending', 'in_progress']) ->whereNull('first_response_at') ->count(); } catch (\Throwable $e) { } // Customers = distinct visitor emails seen in support tickets — // proxy for "people we've supported" until the explicit // support_customers table is populated. try { $supportCustomersCount = (int) \App\Models\SupportTicket::query() ->whereNotNull('email') ->distinct('email') ->count('email'); } catch (\Throwable $e) { } try { $supportPlaybooksCount = (int) \App\Models\Playbook::where('is_active', true)->count(); } catch (\Throwable $e) { } // Marketing group — only count "live" rows so the badge tells // admins what visitors actually see. try { $announcementsCount = (int) \App\Models\Announcement::query() ->when(\Schema::hasColumn('announcements', 'is_active'), fn($q) => $q->where('is_active', true)) ->count(); } catch (\Throwable $e) { } try { $guidebookCount = (int) \App\Models\GuidebookArticle::query() ->when(\Schema::hasColumn('guidebook_articles', 'is_published'), fn($q) => $q->where('is_published', true)) ->count(); } catch (\Throwable $e) { } $nav = [ [ 'type' => 'leaf', 'key' => 'overview', 'href' => url('/admin'), 'label' => __('Overview'), 'icon' => '', 'sw' => 1.6, ], [ 'type' => 'leaf', 'key' => 'financial', 'href' => url('/admin/financial'), 'label' => __('Financial'), 'icon' => '', 'sw' => 1.6, ], [ 'type' => 'leaf', 'key' => 'premium', 'href' => url('/admin/premium'), 'label' => __('Premium'), 'icon' => '', 'sw' => 1.4, ], [ 'type' => 'leaf', 'key' => 'analytics', 'href' => url('/admin/analytics'), 'label' => __('Analytics'), 'icon' => '', 'sw' => 1.6, ], [ 'type' => 'leaf', 'key' => 'ai-dashboard', 'href' => url('/admin/ai-dashboard'), 'label' => __('AI Dashboard'), 'icon' => '', 'sw' => 1.5, ], [ 'type' => 'leaf', 'key' => 'health', 'href' => url('/admin/health'), 'label' => __('System Health'), 'icon' => '', 'sw' => 1.6, ], [ 'type' => 'group', 'key' => 'access', 'label' => __('Users & access'), 'icon' => '', 'sw' => 1.5, 'children' => [ [ 'key' => 'users', 'href' => url('/admin/users'), 'label' => __('Users'), 'badge' => $usersCount > 0 ? $fmtCount($usersCount) : null, ], [ 'key' => 'roles', 'href' => url('/admin/roles'), 'label' => __('Roles'), 'badge' => $rolesCount > 0 ? (string) $rolesCount : null, ], [ 'key' => 'permissions', 'href' => url('/admin/permissions'), 'label' => __('Permissions'), 'badge' => $permsCount > 0 ? (string) $permsCount : null, ], [ 'key' => 'devices', 'href' => url('/admin/devices'), 'label' => __('Devices'), 'badge' => $devicesCount > 0 ? $fmtCount($devicesCount) : null, ], ], ], [ 'type' => 'leaf', 'key' => 'workspaces', 'href' => url('/admin/workspaces'), 'label' => __('Workspaces'), 'icon' => '', 'sw' => 1.6, 'badge' => $workspacesCount > 0 ? $fmtCount($workspacesCount) : null, ], // ───────────────────────────────────────────────────────────── // Contacts / Meta Ads / Messaging (Campaigns, Broadcasts, Templates, // Flows, Auto-replies) / Platform (Integrations, Webhooks) used to be // commented-out entries here because they duplicate the user side. The // admin pages behind them were static mock-ups that nothing linked to, // so both the routes and the blades have now been removed — do not // re-add menu entries for them without rebuilding the pages first. // // Devices is NOT in that list: it is live, under "Users & access" above. // ───────────────────────────────────────────────────────────── [ 'type' => 'group', 'key' => 'billing', 'label' => __('Billing & plans'), 'icon' => '', 'sw' => 1.6, 'children' => [ [ 'key' => 'packages', 'href' => url('/admin/packages'), 'label' => __('Packages'), 'badge' => $packagesCount > 0 ? (string) $packagesCount : null, ], [ 'key' => 'addons', 'href' => url('/admin/addons'), 'label' => __('Add-ons'), 'badge' => ($c = \App\Models\Package::addons()->count()) > 0 ? (string) $c : null, ], [ 'key' => 'coupons', 'href' => url('/admin/coupons'), 'label' => __('Coupons'), 'badge' => $couponsCount > 0 ? (string) $couponsCount : null, ], [ 'key' => 'billing-history', 'href' => url('/admin/billing-history'), 'label' => __('Billing history'), 'badge' => $billingHistoryCount > 0 ? $fmtCount($billingHistoryCount) : null, ], [ 'key' => 'order-history', 'href' => url('/admin/order-history'), 'label' => __('Order history'), 'badge' => $orderHistoryCount > 0 ? $fmtCount($orderHistoryCount) : null, ], [ 'key' => 'invoices', 'href' => url('/admin/invoices'), 'label' => __('Invoices'), 'badge' => $invoicesCount > 0 ? $fmtCount($invoicesCount) : null, ], // Checkout / pricing controls — tax, refund window, yearly // discount, company invoice identity, AND the auto-renew // (recurring subscriptions) switch. [ 'key' => 'checkout-settings', 'href' => url('/admin/checkout-settings'), 'label' => __('Billing settings'), ], // Wallet rules + affiliate credits — kept inside Billing // because they only control billing-side math (referral // signup credits, credits_per_message, credits_per_currency_minor). [ 'key' => 'wallet-rules', 'href' => url('/admin/settings/wallet-rules'), 'label' => __('Message pricing'), ], // BSP income (P&L): what every delivered message earned vs what // Meta charged us — reads the message_charges ledger. [ 'key' => 'bsp', 'href' => url('/admin/bsp'), 'label' => __('Message income'), ], // Reseller model: attach WaDesk's own Meta credit line so Meta // bills the platform and the platform bills the customer. [ 'key' => 'bsp-credit', 'href' => url('/admin/bsp/credit'), 'label' => __('Reseller billing (Meta)'), ], ], ], [ 'type' => 'group', 'key' => 'support', 'label' => __('Support'), 'icon' => '', 'sw' => 1.6, 'badge' => $supportOpen + $contactUnread > 0 ? (string) ($supportOpen + $contactUnread) : null, 'badgeStyle' => 'coral', 'children' => [ [ 'key' => 'support', 'href' => url('/admin/support'), 'label' => __('Inbox'), 'badge' => $supportOpen > 0 ? (string) $supportOpen : null, 'badgeStyle' => 'coral', ], [ 'key' => 'contact-messages', 'href' => url('/admin/contact-messages'), 'label' => __('Contact inbox'), 'badge' => $contactUnread > 0 ? (string) $contactUnread : null, 'badgeStyle' => 'coral', ], [ 'key' => 'support-team', 'href' => url('/admin/support/team-inbox'), 'label' => __('Team inbox'), 'badge' => $supportTeamCount > 0 ? (string) $supportTeamCount : null, ], [ 'key' => 'support-agents', 'href' => url('/admin/support/agents'), 'label' => __('Agents'), 'badge' => $supportAgentsCount > 0 ? (string) $supportAgentsCount : null, ], [ 'key' => 'support-sla', 'href' => url('/admin/support/sla'), 'label' => __('SLA board'), 'badge' => $supportSlaCount > 0 ? (string) $supportSlaCount : null, 'badgeStyle' => $supportSlaCount > 0 ? 'coral' : null, ], [ 'key' => 'support-customers', 'href' => url('/admin/support/customers'), 'label' => __('Customers'), 'badge' => $supportCustomersCount > 0 ? $fmtCount($supportCustomersCount) : null, ], [ 'key' => 'support-playbooks', 'href' => url('/admin/support/playbooks'), 'label' => __('Playbooks'), 'badge' => $supportPlaybooksCount > 0 ? (string) $supportPlaybooksCount : null, ], ['key' => 'support-reports', 'href' => url('/admin/support/reports'), 'label' => __('Reports')], ], ], [ 'type' => 'group', 'key' => 'marketing', 'label' => __('Marketing'), 'icon' => '', 'sw' => 1.5, 'children' => [ [ 'key' => 'announcements', 'href' => url('/admin/announcements'), 'label' => __('Announcements'), 'badge' => $announcementsCount > 0 ? (string) $announcementsCount : null, ], [ 'key' => 'email-campaigns', 'href' => url('/admin/email-campaigns'), 'label' => __('Email campaigns'), ], [ 'key' => 'guidebook', 'href' => url('/admin/guidebook'), 'label' => __('Guidebook'), 'badge' => $guidebookCount > 0 ? (string) $guidebookCount : null, ], ], ], /* Analytics — duplicates user /analytics ['type' => 'leaf', 'key' => 'analytics-dup', 'href' => url('/admin/analytics'), 'label' => __('Analytics'), 'icon' => '', 'sw' => 1.6], */ ]; $sys = [ [ 'key' => 'channel-setting', 'href' => url('/admin/settings/channel-setting'), 'label' => __('Channel Settings'), 'icon' => '', 'sw' => 1.6, ], [ 'key' => 'prebuilt-templates', 'href' => route('admin.prebuilt-templates.index'), 'label' => __('Pre-built Templates'), 'icon' => '', 'sw' => 1.5, ], // Currencies, Languages, Payment gateways, AI/API keys, Audit // log all live under Settings as tiles now — removed from the // System rail to keep that rail short and focused on what's // genuinely "system": WaDesk message provider, Security, and // the Settings hub itself. [ 'key' => 'features', 'href' => url('/admin/settings/features'), 'label' => __('Feature toggles'), 'icon' => '', 'sw' => 1.6, ], [ 'key' => 'frontend', 'href' => url('/admin/frontend'), 'label' => __('Frontend editor'), 'icon' => '', 'sw' => 1.6, ], [ 'key' => 'security', 'href' => url('/admin/security'), 'label' => __('Security'), 'icon' => '', 'sw' => 1.6, ], [ 'key' => 'storage', 'href' => url('/admin/storage'), 'label' => __('Storage'), 'icon' => '', 'sw' => 1.6, ], [ 'key' => 'realtime', 'href' => url('/admin/settings/realtime'), 'label' => __('Real-time'), 'icon' => '', 'sw' => 1.6, ], [ 'key' => 'scaling', 'href' => url('/admin/settings/scaling'), 'label' => __('Advanced Scaling'), 'icon' => '', 'sw' => 1.6, ], /* Hidden for now — Shipping / Tracking settings removed from the sidebar. [ 'key' => 'shipping', 'href' => url('/admin/settings/shipping'), 'label' => __('Shipping / Tracking'), 'icon' => '', 'sw' => 1.6, ], */ [ 'key' => 'support-bot', 'href' => url('/admin/settings/support-bot'), 'label' => __('Support Bot'), 'icon' => '', 'sw' => 1.4, ], [ 'key' => 'blog', 'href' => url('/admin/blog'), 'label' => __('Blog'), 'icon' => '', 'sw' => 1.6, ], [ 'key' => 'flow-templates', 'href' => url('/admin/flow-templates'), 'label' => __('Flow templates'), 'icon' => '', 'sw' => 1.5, ], [ 'key' => 'settings', 'href' => url('/admin/settings'), 'label' => __('Settings'), 'icon' => '', 'sw' => 1.5, ], ]; // Nav contributed by installed extensions (Instagram is the first). Merged // here rather than hardcoded above so the entry appears when the extension is // installed and disappears when it is disabled — no core edit either way. foreach (\App\Services\ExtensionRegistry::nav('admin') as $extItem) { // Instagram's admin entry now lives on the Channel Settings hub as a card // (moved out of the System rail), so skip it here to avoid a duplicate. if (($extItem['key'] ?? '') === 'instagram') { continue; } $sys[] = $extItem; } @endphp
@php // Resolve the logo for the user's currently-selected theme. // Falls back through paper → null. When null we render the // legacy SVG+wordmark so nothing breaks if no logo's uploaded. $brandTheme = \App\Support\Brand::activeTheme(); $brandLogo = \App\Support\Brand::logoUrl($brandTheme); $brandName = (string) brand_name(); @endphp @if ($brandLogo) {{-- data-brand-logo lets wadesk.js setTheme() swap the src to the matching per-theme logo at theme-change time. --}} {{ $brandName }} @else {{ $brandName }} {{ __('Admin console') }} @endif
@php // Admin sidebar icons → vendored Lucide glyphs (ISC). Keyed by each nav // item's own key ($nav + $sys). Any key not listed keeps its inline SVG. $iconMap = [ 'overview' => 'layout-dashboard', 'financial' => 'wallet', 'premium' => 'gem', 'analytics' => 'chart-column', 'ai-dashboard' => 'sparkles', 'health' => 'activity', 'access' => 'users', 'workspaces' => 'building-2', 'billing' => 'credit-card', 'support' => 'life-buoy', 'marketing' => 'megaphone', 'channel-setting' => 'plug', 'prebuilt-templates' => 'layout-template', 'features' => 'toggle-right', 'frontend' => 'globe', 'security' => 'shield', 'storage' => 'hard-drive', 'realtime' => 'zap', 'scaling' => 'server', 'shipping' => 'truck', 'support-bot' => 'bot', 'blog' => 'newspaper', 'flow-templates' => 'workflow', 'settings' => 'settings', ]; @endphp