schema([ Forms\Components\TextInput::make('name') ->required() ->maxLength(255), Forms\Components\TextInput::make('email') ->email() ->required() ->maxLength(255), Forms\Components\Select::make('id_role') ->relationship('role', 'libelle') ->required(), Forms\Components\TextInput::make('password') ->password() ->dehydrated(fn ($state) => filled($state)) ->required(fn (string $context): bool => $context === 'create'), Forms\Components\Toggle::make('is_active') ->label('Compte actif') ->default(true) ->required(), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name') ->searchable(), Tables\Columns\TextColumn::make('email') ->searchable(), Tables\Columns\TextColumn::make('role.libelle') ->label('Rôle') ->badge() ->color(fn (string $state): string => match ($state) { 'Admin' => 'danger', 'Utilisateur' => 'info', default => 'gray', }), Tables\Columns\ToggleColumn::make('is_active') ->label('Actif'), Tables\Columns\TextColumn::make('created_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ Tables\Filters\TernaryFilter::make('is_active') ->label('Statut') ->boolean() ->trueLabel('Utilisateurs actifs') ->falseLabel('Utilisateurs désactivés') ->native(false), ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } 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'), ]; } }