@php use App\Models\ManagedEnvironment; use App\Models\User; use App\Support\ManagedEnvironmentLinks; use App\Support\OperateHub\OperateHubShell; use Filament\Facades\Filament; $resolvedContext = app(OperateHubShell::class)->resolvedContext(request()); $workspace = $resolvedContext->workspace; $environment = $resolvedContext->tenant; $isEnvironmentScope = $resolvedContext->pageCategory->requiresExplicitEnvironment() && $environment instanceof ManagedEnvironment; $environmentDisplayName = static function (ManagedEnvironment $environment): string { $displayName = trim((string) ($environment->display_name ?: $environment->name ?: $environment->external_id ?: '')); return $displayName !== '' ? $displayName : 'Environment #'.$environment->getKey(); }; $scopeUrl = $isEnvironmentScope ? ManagedEnvironmentLinks::viewUrl($environment) : route('admin.home'); $scopeKind = $isEnvironmentScope ? __('localization.shell.environment_scope_short') : __('localization.shell.workspace_scope_short'); $scopeName = $isEnvironmentScope ? $environmentDisplayName($environment) : $workspace?->name; $workspaceEnvironmentCount = 0; $sidebarUser = auth()->user(); if ($sidebarUser instanceof User && $workspace) { $workspaceEnvironmentCount = collect($sidebarUser->getTenants(Filament::getCurrentOrDefaultPanel())) ->filter(fn ($candidate): bool => $candidate instanceof ManagedEnvironment && (int) $candidate->workspace_id === (int) $workspace->getKey()) ->count(); } $scopeDescription = $isEnvironmentScope ? __('localization.shell.workspace_context_label', ['workspace' => $workspace?->name]) : trans_choice('localization.shell.environment_count', $workspaceEnvironmentCount, ['count' => $workspaceEnvironmentCount]); $scopeActionLabel = __('localization.shell.scope_indicator_action', ['scope' => $scopeName]); @endphp @if ($workspace) {{ $scopeKind }} {{ $scopeName }} {{ $scopeDescription }} @endif