You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.4 KiB

// 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<String, dynamic> 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<String, dynamic> toMapWithId() {
final map = toMap();
if (id != null) map['id'] = id;
return map;
}
factory Users.fromMap(Map<String, dynamic> 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 ?? '';
}