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.
59 lines
1.3 KiB
59 lines
1.3 KiB
class Users {
|
|
int? id;
|
|
String name;
|
|
String lastName;
|
|
String email;
|
|
String password;
|
|
String username;
|
|
int roleId;
|
|
String? roleName; // Optionnel, rempli lors des requêtes avec JOIN
|
|
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,
|
|
'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'],
|
|
name: map['name'],
|
|
lastName: map['lastname'],
|
|
email: map['email'],
|
|
password: map['password'],
|
|
username: map['username'],
|
|
roleId: map['role_id'],
|
|
roleName: map['role_name'], // Depuis les requêtes avec JOIN
|
|
pointDeVenteId : map['point_de_vente_id']
|
|
);
|
|
}
|
|
|
|
// Getter pour la compatibilité avec l'ancien code
|
|
String get role => roleName ?? '';
|
|
|
|
}
|