121 lines
3.1 KiB
Dart
121 lines
3.1 KiB
Dart
class VendorBookingModel {
|
|
int? id;
|
|
String? name;
|
|
String? mobileNumber;
|
|
String? email;
|
|
String? message;
|
|
String? serviceDate;
|
|
String? serviceTime;
|
|
int? serviceId;
|
|
int? userId;
|
|
String? address;
|
|
int? status;
|
|
String? type;
|
|
String? cancelDate;
|
|
String? createdDate;
|
|
String? serviceName;
|
|
|
|
String? username;
|
|
String? workingHours;
|
|
String? categoryName;
|
|
String? images1; // Added missing field
|
|
String? profilePic1; // Added missing field
|
|
|
|
VendorBookingModel({
|
|
this.id,
|
|
this.name,
|
|
this.mobileNumber,
|
|
this.email,
|
|
this.message,
|
|
this.serviceDate,
|
|
this.serviceTime,
|
|
this.serviceId,
|
|
this.userId,
|
|
this.address,
|
|
this.status,
|
|
this.type,
|
|
this.cancelDate,
|
|
this.createdDate,
|
|
this.serviceName,
|
|
|
|
this.username,
|
|
this.workingHours,
|
|
this.categoryName,
|
|
this.images1, // Added to constructor
|
|
this.profilePic1, // Added to constructor
|
|
});
|
|
|
|
VendorBookingModel.fromJson(Map<String, dynamic> json) {
|
|
// Helper function to safely convert values to int
|
|
int? toInt(dynamic value) {
|
|
if (value == null) return null;
|
|
if (value is int) return value;
|
|
if (value is String) {
|
|
try {
|
|
return int.parse(value);
|
|
} catch (e) {
|
|
print('Error parsing to int: $value');
|
|
return null;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// Helper function to safely convert values to string
|
|
String? toString(dynamic value) {
|
|
if (value == null) return null;
|
|
return value.toString();
|
|
}
|
|
|
|
id = toInt(json['id']);
|
|
name = toString(json['name']);
|
|
mobileNumber = toString(json['mobile_number']);
|
|
email = toString(json['email']);
|
|
message = toString(json['message']);
|
|
serviceDate = toString(json['service_date']);
|
|
serviceTime = toString(json['service_time']);
|
|
serviceId = toInt(json['service_id']);
|
|
userId = toInt(json['user_id']);
|
|
address = toString(json['address']);
|
|
status = toInt(json['status']);
|
|
type = toString(json['type']);
|
|
cancelDate = toString(json['cancel_date']);
|
|
createdDate = toString(json['created_date']);
|
|
serviceName = toString(json['service_name']);
|
|
|
|
username = toString(json['username']);
|
|
workingHours = toString(json['workinghours']);
|
|
categoryName = toString(json['category_name']);
|
|
images1 = toString(json['images1']); // Parse images1 from JSON
|
|
profilePic1 = toString(
|
|
json['profile_pic1'],
|
|
); // Parse profile_pic1 from JSON
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'mobile_number': mobileNumber,
|
|
'email': email,
|
|
'message': message,
|
|
'service_date': serviceDate,
|
|
'service_time': serviceTime,
|
|
'service_id': serviceId,
|
|
'user_id': userId,
|
|
'address': address,
|
|
'status': status,
|
|
'type': type,
|
|
'cancel_date': cancelDate,
|
|
'created_date': createdDate,
|
|
'service_name': serviceName,
|
|
|
|
'username': username,
|
|
'workinghours': workingHours,
|
|
'category_name': categoryName,
|
|
'images1': images1, // Include images1 in JSON output
|
|
'profile_pic1': profilePic1, // Include profile_pic1 in JSON output
|
|
};
|
|
}
|
|
}
|