33 lines
682 B
Dart
33 lines
682 B
Dart
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
class UserModel {
|
|
final String uid;
|
|
final String name;
|
|
final String email;
|
|
final DateTime createdAt;
|
|
|
|
UserModel({
|
|
required this.uid,
|
|
required this.name,
|
|
required this.email,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory UserModel.fromMap(String id, Map<String, dynamic> data) {
|
|
return UserModel(
|
|
uid: id,
|
|
name: data['name'] ?? '',
|
|
email: data['email'] ?? '',
|
|
createdAt: (data['createdAt'] as Timestamp).toDate(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'name': name,
|
|
'email': email,
|
|
'createdAt': Timestamp.fromDate(createdAt),
|
|
};
|
|
}
|
|
}
|