110 lines
2.6 KiB
Dart
110 lines
2.6 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
class ProviderLocationModel extends Equatable {
|
|
final String? id;
|
|
final String providerId;
|
|
final String companyId;
|
|
final String name; // Es: "Laboratorio Centrale"
|
|
final String address;
|
|
final String city;
|
|
final String zipCode;
|
|
final String province;
|
|
final String? contactPerson;
|
|
final bool isMain;
|
|
|
|
const ProviderLocationModel({
|
|
this.id,
|
|
required this.providerId,
|
|
required this.companyId,
|
|
required this.name,
|
|
required this.address,
|
|
required this.city,
|
|
required this.zipCode,
|
|
required this.province,
|
|
this.contactPerson,
|
|
this.isMain = false,
|
|
});
|
|
|
|
factory ProviderLocationModel.empty() {
|
|
return const ProviderLocationModel(
|
|
providerId: '',
|
|
companyId: '',
|
|
name: '',
|
|
address: '',
|
|
city: '',
|
|
zipCode: '',
|
|
province: '',
|
|
);
|
|
}
|
|
|
|
ProviderLocationModel copyWith({
|
|
String? id,
|
|
String? providerId,
|
|
String? companyId,
|
|
String? name,
|
|
String? address,
|
|
String? city,
|
|
String? zipCode,
|
|
String? province,
|
|
String? contactPerson,
|
|
bool? isMain,
|
|
}) {
|
|
return ProviderLocationModel(
|
|
id: id ?? this.id,
|
|
providerId: providerId ?? this.providerId,
|
|
companyId: companyId ?? this.companyId,
|
|
name: name ?? this.name,
|
|
address: address ?? this.address,
|
|
city: city ?? this.city,
|
|
zipCode: zipCode ?? this.zipCode,
|
|
province: province ?? this.province,
|
|
contactPerson: contactPerson ?? this.contactPerson,
|
|
isMain: isMain ?? this.isMain,
|
|
);
|
|
}
|
|
|
|
factory ProviderLocationModel.fromMap(Map<String, dynamic> map) {
|
|
return ProviderLocationModel(
|
|
id: map['id'] as String,
|
|
providerId: map['provider_id'] as String,
|
|
companyId: map['company_id'] as String,
|
|
name: map['name'] as String,
|
|
address: map['address'] as String,
|
|
city: map['city'] as String,
|
|
zipCode: map['zip_code'] as String,
|
|
province: map['province'] as String,
|
|
contactPerson: map['contact_person'] as String?,
|
|
isMain: map['is_main'] as bool? ?? false,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
if (id != null) 'id': id,
|
|
'provider_id': providerId,
|
|
'company_id': companyId,
|
|
'name': name,
|
|
'address': address,
|
|
'city': city,
|
|
'zip_code': zipCode,
|
|
'province': province,
|
|
'contact_person': contactPerson,
|
|
'is_main': isMain,
|
|
};
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
id,
|
|
providerId,
|
|
companyId,
|
|
name,
|
|
address,
|
|
city,
|
|
zipCode,
|
|
province,
|
|
contactPerson,
|
|
isMain,
|
|
];
|
|
}
|