Eliminar creche_app/lib/models/child.dart
This commit is contained in:
parent
f117f6ce88
commit
c3d9619d4c
|
|
@ -1,70 +0,0 @@
|
|||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class Child {
|
||||
final String id;
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
final DateTime birthDate;
|
||||
final String? photoUrl;
|
||||
final String classId;
|
||||
final String teacherId;
|
||||
final String status;
|
||||
final String? mood;
|
||||
final String? allergies; // ← NOVO
|
||||
final String? foodRestrictions; // ← NOVO
|
||||
final String? roomId; // ← NOVO
|
||||
|
||||
Child({
|
||||
String? id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.birthDate,
|
||||
this.photoUrl,
|
||||
required this.classId,
|
||||
required this.teacherId,
|
||||
this.status = 'active',
|
||||
this.mood,
|
||||
this.allergies,
|
||||
this.foodRestrictions,
|
||||
this.roomId,
|
||||
}) : id = id ?? const Uuid().v4();
|
||||
|
||||
int get age {
|
||||
final today = DateTime.now();
|
||||
int a = today.year - birthDate.year;
|
||||
if (today.month < birthDate.month ||
|
||||
(today.month == birthDate.month && today.day < birthDate.day)) a--;
|
||||
return a;
|
||||
}
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
|
||||
factory Child.fromMap(Map<String, dynamic> map) => Child(
|
||||
id: map['id'],
|
||||
firstName: map['first_name'] ?? '',
|
||||
lastName: map['last_name'] ?? '',
|
||||
birthDate: DateTime.tryParse(map['birth_date'] ?? '') ?? DateTime.now(),
|
||||
photoUrl: map['photo_url'],
|
||||
classId: map['class_id'] ?? '',
|
||||
teacherId: map['teacher_id'] ?? '',
|
||||
status: map['status'] ?? 'active',
|
||||
mood: map['mood'],
|
||||
allergies: map['allergies'],
|
||||
foodRestrictions: map['food_restrictions'],
|
||||
roomId: map['room_id'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
'id': id,
|
||||
'first_name': firstName,
|
||||
'last_name': lastName,
|
||||
'birth_date': birthDate.toIso8601String().split('T')[0],
|
||||
'photo_url': photoUrl,
|
||||
'class_id': classId,
|
||||
'teacher_id': teacherId,
|
||||
'status': status,
|
||||
'allergies': allergies,
|
||||
'food_restrictions': foodRestrictions,
|
||||
'room_id': roomId,
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue