columns([ TextColumn::make('name')->label('Name')->searchable(), TextColumn::make('email')->label('E-Mail')->searchable(), TextColumn::make('role') ->label('Rolle') ->badge() ->state(function (User $record): ?UserRole { $tenantId = app(TenantContext::class)->id(); if ($tenantId === null) { return $record->role; } return $record->roleOn($tenantId) ?? $record->role; }), TextColumn::make('mode')->label('Ansicht')->state(fn (User $record): string => $record->adminMode()->getLabel()), IconColumn::make('two_factor')->label('2FA')->state(fn (User $record): bool => filled($record->getAppAuthenticationSecret()))->boolean(), ]) ->recordActions([ EditAction::make(), Action::make('resetTwoFactor') ->label('2FA zurücksetzen') ->icon(Heroicon::OutlinedKey) ->color('warning') ->requiresConfirmation() ->modalDescription('Zum Beispiel bei verlorenem Handy: Die Person richtet die Zwei-Faktor-Anmeldung bei der nächsten Anmeldung neu ein.') ->visible(function (User $record): bool { $actor = auth()->user(); return filled($record->getAppAuthenticationSecret()) && $actor instanceof User && $actor->mayResetCredentials($record); }) ->action(function (User $record): void { $actor = auth()->user(); if (! $actor instanceof User || ! $actor->mayResetCredentials($record)) { return; } $record->saveAppAuthenticationSecret(null); $record->saveAppAuthenticationRecoveryCodes(null); Notification::make()->title('2FA zurückgesetzt')->success()->send(); }), Action::make('revokeAccess') ->label('Zugang entziehen') ->icon(Heroicon::OutlinedNoSymbol) ->color('danger') ->requiresConfirmation() ->modalDescription('Das Konto bleibt bestehen und verliert nur den Zugang zu diesem Mandanten. Passwort und Zwei-Faktor-Anmeldung bleiben.') ->visible(fn (User $record): bool => $record->tenants()->count() >= 2) ->action(function (User $record): void { $record->revokeCurrentTenant(); Notification::make()->title('Zugang entzogen')->success()->send(); }), DeleteAction::make(), ]); } }