products data
This commit is contained in:
57
lib/features/products/models/brand_model.dart
Normal file
57
lib/features/products/models/brand_model.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class BrandModel extends Equatable {
|
||||
final String? id;
|
||||
final String name;
|
||||
final String companyId;
|
||||
final bool isActive;
|
||||
final DateTime? createdAt;
|
||||
|
||||
const BrandModel({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.companyId,
|
||||
this.isActive = true,
|
||||
this.createdAt,
|
||||
});
|
||||
|
||||
factory BrandModel.fromJson(Map<String, dynamic> json) {
|
||||
return BrandModel(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
companyId: json['company_id'] as String,
|
||||
isActive: json['is_active'] as bool? ?? true,
|
||||
createdAt: json['created_at'] != null
|
||||
? DateTime.parse(json['created_at'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'name': name,
|
||||
'company_id': companyId,
|
||||
'is_active': isActive,
|
||||
};
|
||||
}
|
||||
|
||||
BrandModel copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
String? companyId,
|
||||
bool? isActive,
|
||||
DateTime? createdAt,
|
||||
}) {
|
||||
return BrandModel(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
companyId: companyId ?? this.companyId,
|
||||
isActive: isActive ?? this.isActive,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, name, companyId, isActive, createdAt];
|
||||
}
|
||||
70
lib/features/products/models/model_model.dart
Normal file
70
lib/features/products/models/model_model.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class ModelModel extends Equatable {
|
||||
final String? id;
|
||||
final String name;
|
||||
final String nameWithBrand;
|
||||
final String brandId;
|
||||
final bool isActive;
|
||||
final DateTime? createdAt;
|
||||
|
||||
const ModelModel({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.nameWithBrand,
|
||||
required this.brandId,
|
||||
this.isActive = true,
|
||||
this.createdAt,
|
||||
});
|
||||
|
||||
factory ModelModel.fromJson(Map<String, dynamic> json) {
|
||||
return ModelModel(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
nameWithBrand: json['name_with_brand'] as String,
|
||||
brandId: json['brand_id'] as String,
|
||||
isActive: json['is_active'] as bool? ?? true,
|
||||
createdAt: json['created_at'] != null
|
||||
? DateTime.parse(json['created_at'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'name': name,
|
||||
'name_with_brand': nameWithBrand,
|
||||
'brand_id': brandId,
|
||||
'is_active': isActive,
|
||||
};
|
||||
}
|
||||
|
||||
ModelModel copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
String? nameWithBrand,
|
||||
String? brandId,
|
||||
bool? isActive,
|
||||
DateTime? createdAt,
|
||||
}) {
|
||||
return ModelModel(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
nameWithBrand: nameWithBrand ?? this.nameWithBrand,
|
||||
brandId: brandId ?? this.brandId,
|
||||
isActive: isActive ?? this.isActive,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
name,
|
||||
nameWithBrand,
|
||||
brandId,
|
||||
isActive,
|
||||
createdAt,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user