schema([ TextInput::make('name')->required()->maxLength(255), TextInput::make('email')->email()->required()->maxLength(255)->unique(ignoreRecord: true), TextInput::make('password')->password()->required(fn ($livewire) => $livewire instanceof Pages\CreateUser)->dehydrateStateUsing(fn ($state) => filled($state) ? bcrypt($state) : null)->dehydrated(fn ($state) => filled($state)), Select::make('roles')->multiple()->relationship('roles', 'name')->preload(), ]); } public static function table(Table $table): Table { return $table->columns([ TextColumn::make('id')->sortable(), TextColumn::make('name')->searchable()->sortable(), TextColumn::make('email')->searchable()->sortable(), TextColumn::make('roles.name')->badge()->label('Roles'), TextColumn::make('created_at')->dateTime()->sortable(), ])->actions([EditAction::make(), DeleteAction::make()]); } public static function getPages(): array { return [ 'index' => Pages\ListUsers::route('/'), 'create' => Pages\CreateUser::route('/create'), 'edit' => Pages\EditUser::route('/{record}/edit'), ]; } }