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.4 KiB

10 months ago
// Models/users.dart - Version corrigée
10 months ago
class Users {
10 months ago
int? id;
10 months ago
String name;
String lastName;
String email;
String password;
String username;
10 months ago
int roleId;
10 months ago
String? roleName;
int? pointDeVenteId;
10 months ago
Users({
10 months ago
this.id,
10 months ago
required this.name,
required this.lastName,
required this.email,
required this.password,
required this.username,
10 months ago
required this.roleId,
this.roleName,
this.pointDeVenteId,
10 months ago
});
Map<String, dynamic> toMap() {
return {
'name': name,
10 months ago
'lastname': lastName, // Correspond à la colonne DB
10 months ago
'email': email,
'password': password,
'username': username,
10 months ago
'role_id': roleId,
10 months ago
'point_de_vente_id': pointDeVenteId,
10 months ago
};
}
10 months ago
Map<String, dynamic> toMapWithId() {
final map = toMap();
if (id != null) map['id'] = id;
return map;
}
10 months ago
factory Users.fromMap(Map<String, dynamic> map) {
return Users(
10 months ago
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?,
10 months ago
);
}
10 months ago
String get role => roleName ?? '';
10 months ago
}