> */ public array $rows = []; public ?int $tenantFilter = null; public static function actionSurfaceDeclaration(): ActionSurfaceDeclaration { return ActionSurfaceDeclaration::forPage(ActionSurfaceProfile::ListOnlyReadOnly) ->satisfy(ActionSurfaceSlot::ListHeader, 'The overview header exposes a clear-filters action when a tenant prefilter is active.') ->satisfy(ActionSurfaceSlot::InspectAffordance, ActionSurfaceInspectAffordance::ClickableRow->value) ->exempt(ActionSurfaceSlot::ListRowMoreMenu, 'The overview exposes a single drill-down link per row without a More menu.') ->exempt(ActionSurfaceSlot::ListBulkMoreGroup, 'The overview does not expose bulk actions.') ->satisfy(ActionSurfaceSlot::ListEmptyState, 'The empty state explains the current scope and offers a clear-filters CTA.'); } public function mount(): void { $user = auth()->user(); if (! $user instanceof User) { throw new AuthenticationException; } $workspaceContext = app(WorkspaceContext::class); $workspace = $workspaceContext->currentWorkspaceForMemberOrFail($user, request()); $workspaceId = (int) $workspace->getKey(); $accessibleTenants = $user->tenants() ->where('tenants.workspace_id', $workspaceId) ->orderBy('tenants.name') ->get() ->filter(fn (Tenant $tenant): bool => (int) $tenant->workspace_id === $workspaceId && $user->can('evidence.view', $tenant)) ->values(); $this->tenantFilter = is_numeric(request()->query('tenant_id')) ? (int) request()->query('tenant_id') : null; $tenantIds = $accessibleTenants->pluck('id')->map(static fn (mixed $id): int => (int) $id)->all(); $query = EvidenceSnapshot::query() ->with('tenant') ->where('workspace_id', $workspaceId) ->whereIn('tenant_id', $tenantIds) ->where('status', 'active') ->latest('generated_at'); if ($this->tenantFilter !== null) { $query->where('tenant_id', $this->tenantFilter); } $snapshots = $query->get()->unique('tenant_id')->values(); $this->rows = $snapshots->map(function (EvidenceSnapshot $snapshot): array { return [ 'tenant_name' => $snapshot->tenant?->name ?? 'Unknown tenant', 'tenant_id' => (int) $snapshot->tenant_id, 'snapshot_id' => (int) $snapshot->getKey(), 'completeness_state' => (string) $snapshot->completeness_state, 'generated_at' => $snapshot->generated_at?->toDateTimeString(), 'missing_dimensions' => (int) (($snapshot->summary['missing_dimensions'] ?? 0)), 'stale_dimensions' => (int) (($snapshot->summary['stale_dimensions'] ?? 0)), 'view_url' => EvidenceSnapshotResource::getUrl('index', tenant: $snapshot->tenant), ]; })->all(); } /** * @return array */ protected function getHeaderActions(): array { return [ Action::make('clear_filters') ->label('Clear filters') ->color('gray') ->visible(fn (): bool => $this->tenantFilter !== null) ->url(route('admin.evidence.overview')), ]; } }