// Models/users.dart - Version corrigée class Users { int? id; String name; String lastName; String email; String password; String username; int roleId; String? roleName; int? pointDeVenteId; Users({ this.id, required this.name, required this.lastName, required this.email, required this.password, required this.username, required this.roleId, this.roleName, this.pointDeVenteId, }); Map toMap() { return { 'name': name, 'lastname': lastName, // Correspond à la colonne DB 'email': email, 'password': password, 'username': username, 'role_id': roleId, 'point_de_vente_id': pointDeVenteId, }; } Map toMapWithId() { final map = toMap(); if (id != null) map['id'] = id; return map; } factory Users.fromMap(Map map) { return Users( id: map['id'] as int?, name: map['name'] as String, lastName: map['lastname'] as String, // Correspond à la colonne DB email: map['email'] as String, password: map['password'] as String, username: map['username'] as String, roleId: map['role_id'] as int, roleName: map['role_name'] as String?, // Depuis les JOINs pointDeVenteId: map['point_de_vente_id'] as int?, ); } String get role => roleName ?? ''; }