user()?->can('users.manage') ?? false; } public static function form(Schema $schema): Schema { return $schema ->columns(2) ->components([ TextInput::make('label')->label('Bezeichnung')->required()->maxLength(100), TextInput::make('key')->label('Technischer Schlüssel') ->helperText('Wird aus der Bezeichnung erzeugt, wenn leer. Nachträglich nicht änderbar.') ->regex('/^[a-z][a-z0-9_]*$/') ->validationMessages(['regex' => 'Nur Kleinbuchstaben, Ziffern und Unterstriche, beginnend mit einem Buchstaben.']) ->maxLength(60) ->unique(ignoreRecord: true) ->disabledOn('edit'), Select::make('type')->label('Typ')->options(ProfileField::TYPES)->default('text')->required()->native(false), Select::make('visibility')->label('Sichtbarkeit')->options(ProfileField::VISIBILITIES)->default('public')->required()->native(false), Toggle::make('editable')->label('Von der Person selbst pflegbar')->default(true) ->helperText('Aus Entra ID übernommene Felder sind unabhängig davon schreibgeschützt.'), TextInput::make('sort')->label('Reihenfolge')->numeric()->default(0)->minValue(0), TextInput::make('help')->label('Hinweis im Profilformular')->maxLength(255)->columnSpanFull(), ]); } public static function table(Table $table): Table { return $table ->defaultSort('sort') ->reorderable('sort') ->columns([ TextColumn::make('label')->label('Bezeichnung')->weight('medium'), TextColumn::make('key')->label('Schlüssel')->fontFamily('mono')->color('gray'), TextColumn::make('type')->label('Typ')->formatStateUsing(fn (string $state) => ProfileField::TYPES[$state] ?? $state), TextColumn::make('visibility')->label('Sichtbarkeit')->badge() ->formatStateUsing(fn (string $state) => $state === 'public' ? 'Alle' : 'Eingeschränkt') ->color(fn (string $state) => $state === 'public' ? 'gray' : 'warning'), IconColumn::make('editable')->label('Selbst pflegbar')->boolean(), ]) ->recordActions([ EditAction::make(), DeleteAction::make()->modalDescription('Die gespeicherten Werte bleiben erhalten, werden aber nicht mehr angezeigt.'), ]) ->emptyStateHeading('Noch keine Profilfelder') ->emptyStateDescription('Zum Beispiel Personalnummer, Kostenstelle oder Eintrittsdatum – selbst gepflegt oder aus Entra ID übernommen.'); } public static function getPages(): array { return [ 'index' => ManageProfileFields::route('/'), ]; } }