user(); return $user instanceof PlatformUser && $user->hasCapability(PlatformCapabilities::DIRECTORY_VIEW); } public function mount(Tenant $tenant): void { $tenant->load('workspace'); $this->tenant = $tenant; } /** * @return Collection */ public function providerConnections(): Collection { return ProviderConnection::query() ->where('tenant_id', (int) $this->tenant->getKey()) ->orderByDesc('is_default') ->orderBy('provider') ->get(['id', 'provider', 'status', 'health_status', 'is_default', 'last_health_check_at']); } /** * @return Collection */ public function tenantPermissions(): Collection { return TenantPermission::query() ->where('tenant_id', (int) $this->tenant->getKey()) ->orderBy('permission_key') ->limit(20) ->get(['id', 'permission_key', 'status', 'last_checked_at']); } /** * @return Collection */ public function recentRuns(): Collection { return OperationRun::query() ->where('tenant_id', (int) $this->tenant->getKey()) ->latest('id') ->limit(8) ->get(['id', 'type', 'created_at']) ->map(fn (OperationRun $run): array => [ 'id' => (int) $run->getKey(), 'label' => OperationCatalog::label((string) $run->type), 'started' => $run->created_at?->diffForHumans() ?? '—', 'url' => SystemOperationRunLinks::view($run), ]); } public function adminTenantUrl(): string { return SystemDirectoryLinks::adminTenant($this->tenant); } public function runsUrl(): string { return SystemOperationRunLinks::index(); } }