import 'dart:convert'; class TableResponseModel { final bool? success; final TableData? data; final dynamic errors; TableResponseModel({ this.success, this.data, this.errors, }); factory TableResponseModel.fromJson(String str) => TableResponseModel.fromMap(json.decode(str)); String toJson() => json.encode(toMap()); factory TableResponseModel.fromMap(Map json) => TableResponseModel( success: json["success"], data: json["data"] == null ? null : TableData.fromMap(json["data"]), errors: json["errors"], ); Map toMap() => { "success": success, "data": data?.toMap(), "errors": errors, }; } class TableData { final List? tables; final int? totalCount; final int? page; final int? limit; final int? totalPages; TableData({ this.tables, this.totalCount, this.page, this.limit, this.totalPages, }); factory TableData.fromMap(Map json) => TableData( tables: json["tables"] == null ? [] : List.from( json["tables"].map((x) => TableModel.fromMap(x))), totalCount: json["total_count"], page: json["page"], limit: json["limit"], totalPages: json["total_pages"], ); Map toMap() => { "tables": tables == null ? [] : List.from(tables!.map((x) => x.toMap())), "total_count": totalCount, "page": page, "limit": limit, "total_pages": totalPages, }; } class TableModel { final String? id; final String? organizationId; final String? outletId; final String? tableName; final String? status; final int? paymentAmount; final double? positionX; final double? positionY; final int? capacity; final bool? isActive; final DateTime? createdAt; final DateTime? updatedAt; TableModel({ this.id, this.organizationId, this.outletId, this.tableName, this.status, this.paymentAmount, this.positionX, this.positionY, this.capacity, this.isActive, this.createdAt, this.updatedAt, }); factory TableModel.fromMap(Map json) => TableModel( id: json["id"], organizationId: json["organization_id"], outletId: json["outlet_id"], tableName: json["table_name"], status: json["status"], paymentAmount: json["payment_amount"], positionX: json["position_x"]?.toDouble(), positionY: json["position_y"]?.toDouble(), capacity: json["capacity"], isActive: json["is_active"], createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]), updatedAt: json["updated_at"] == null ? null : DateTime.parse(json["updated_at"]), ); Map toMap() => { "id": id, "organization_id": organizationId, "outlet_id": outletId, "table_name": tableName, "status": status, "payment_amount": paymentAmount, "position_x": positionX, "position_y": positionY, "capacity": capacity, "is_active": isActive, "created_at": createdAt?.toIso8601String(), "updated_at": updatedAt?.toIso8601String(), }; }