import 'package:taafee_mobile/features/card/data_layer/model/card_model.dart';

class FavoriteModel {
  int id;
  int userId;
  CardModel cardModel;
  FavoriteModel(
      {required this.id, required this.userId, required this.cardModel});

  factory FavoriteModel.fromJson(Map<String, dynamic> json) => FavoriteModel(
        id: json["id"],
        userId: json["user_id"],
        cardModel: CardModel.fromJson(
          json["card"],
        ),
      );

  static List<FavoriteModel> fromJsonList(Map<String, dynamic> json) {
    List<FavoriteModel> favorites = [];
    json["data"].forEach(
      (element) => favorites.add(
        FavoriteModel.fromJson(element),
      ),
    );
    return favorites;
  }
}
