schema([ Section::make('Personal Information') ->schema([ TextInput::make('first_name') ->required() ->maxLength(255), TextInput::make('last_name') ->required() ->maxLength(255), TextInput::make('username') ->required() ->unique(ignoreRecord: true) ->maxLength(255), TextInput::make('email') ->email() ->required() ->unique(ignoreRecord: true), Textarea::make('address') ->required() ->rows(3), TextInput::make('phone') ->required() ->tel(), ]) ->columns(2), Section::make('Password') ->schema([ TextInput::make('password') ->password() ->required(fn (string $operation): bool => $operation === 'create') ->dehydrated(fn (?string $state): bool => filled($state)) ->same('password_confirmation'), TextInput::make('password_confirmation') ->password() ->required(fn (string $operation): bool => $operation === 'create') ->dehydrated(false), ]) ->columns(1), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('fullName')->sortable()->searchable(), TextColumn::make('email')->searchable(), TextColumn::make('username')->searchable(), TextColumn::make('tenant.name') ->label(__('admin.common.tenant')) ->badge(), TextColumn::make('phone'), IconColumn::make('email_verified_at') ->label(__('admin.users.fields.verified')) ->boolean(), ]) ->filters([]) ->actions([ ActionGroup::make([ ViewAction::make(), EditAction::make() ->after(fn (array $data, User $record) => app(SuperAdminAuditLogger::class)->recordModelMutation( 'updated', $record, SuperAdminAuditLogger::fieldsMetadata($data), static::class )), ]), ]) ->bulkActions([ BulkActionGroup::make([ DeleteBulkAction::make() ->after(function (Collection $records): void { $logger = app(SuperAdminAuditLogger::class); foreach ($records as $record) { $logger->recordModelMutation( 'deleted', $record, source: static::class ); } }), ]), ]); } public static function getRelations(): array { return []; } public static function getPages(): array { return [ 'index' => Pages\ListUsers::route('/'), 'create' => Pages\CreateUser::route('/create'), 'edit' => Pages\EditUser::route('/{record}/edit'), ]; } }