@php $currentTenant = filament()->getTenant(); $currentTenantName = filament()->getTenantName($currentTenant); $items = filament()->getTenantMenuItems(); $billingItem = $items['billing'] ?? null; $billingItemUrl = $billingItem?->getUrl(); $isBillingItemVisible = $billingItem?->isVisible() ?? true; $hasBillingItem = (filament()->hasTenantBilling() || filled($billingItemUrl)) && $isBillingItemVisible; $registrationItem = $items['register'] ?? null; $registrationItemUrl = $registrationItem?->getUrl(); $isRegistrationItemVisible = $registrationItem?->isVisible() ?? true; $hasRegistrationItem = ((filament()->hasTenantRegistration() && filament()->getTenantRegistrationPage()::canView()) || filled($registrationItemUrl)) && $isRegistrationItemVisible; $profileItem = $items['profile'] ?? null; $profileItemUrl = $profileItem?->getUrl(); $isProfileItemVisible = $profileItem?->isVisible() ?? true; $hasProfileItem = ((filament()->hasTenantProfile() && filament()->getTenantProfilePage()::canView($currentTenant)) || filled($profileItemUrl)) && $isProfileItemVisible; $tenants = array_filter( filament()->getUserTenants(filament()->auth()->user()), fn (\Illuminate\Database\Eloquent\Model $tenant): bool => ! $tenant->is($currentTenant), ); $canSwitchTenants = count($tenants); $items = \Illuminate\Support\Arr::except($items, ['billing', 'profile', 'register']); // Get current route info $route = \Illuminate\Support\Facades\Route::current(); $routeParams = $route->parameters(); $routeController = $route->getController(); @endphp {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::TENANT_MENU_BEFORE) }} @if ($hasProfileItem || $hasBillingItem) @if ($hasProfileItem) {{ $profileItem?->getLabel() ?? filament()->getTenantProfilePage()::getLabel() }} @endif @if ($hasBillingItem) {{ $billingItem?->getLabel() ?? __('filament-panels::layout.actions.billing.label') }} @endif @endif @if (count($items)) @foreach ($items as $item) @php $itemPostAction = $item->getPostAction(); @endphp {{ $item->getLabel() }} @endforeach @endif @if ($canSwitchTenants) @foreach ($tenants as $tenant) @php $hasAccess = $routeController->canAccess(); $routeName = $route->getName(); $newRouteName = $routeName; if (str_ends_with($routeName, '.view') || str_ends_with($routeName, '.edit')) { $newRouteName = str_replace(['.view', '.edit'], '.index', $routeName); } if(str_ends_with($routeName, '.activities')) { $newRouteName = str_replace(['.activities'], '.index', $routeName); } $redirectUrl = route($newRouteName, ['tenant' => $tenant->id]); @endphp {{ filament()->getTenantName($tenant) }} @endforeach @endif @if ($hasRegistrationItem) {{ $registrationItem?->getLabel() ?? filament()->getTenantRegistrationPage()::getLabel() }} @endif {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::TENANT_MENU_AFTER) }}