import 'package:initial_folder/models/comment_qna_model.dart'; class QnaModel { QnaModel({ this.status, this.error, required this.data, }); final int? status; final bool? error; final List> data; factory QnaModel.fromJson(Map json) => QnaModel( status: json["status"], error: json["error"], data: List>.from(json["data"].map((x) => List.from(x.map((x) => QnaDataModel.fromJson(x))))), ); Map toJson() => { "status": status, "error": error, "data": List.from( data.map((x) => List.from(x.map((x) => x.toJson())))), }; } class QnaDataModel { QnaDataModel({ this.idQna, this.idLesson, this.sender, this.username, this.title, this.quest, this.fotoProfile, this.countComment, this.countLike, this.selfLiked, this.date, required this.comment, }); final String? idQna; final String? idLesson; final String? sender; final String? username; final String? title; final String? quest; final String? fotoProfile; int? countComment; String? countLike; bool? selfLiked; final String? date; List comment; factory QnaDataModel.fromJson(Map json) => QnaDataModel( idQna: json["id_qna"], idLesson: json["id_lesson"], sender: json["sender"], username: json["username"], title: json["title"], quest: json["quest"], fotoProfile: json["foto_profile"], countComment: json["count_comment"], countLike: json["count_up"], selfLiked: json['status_up'], date: json["date"], comment: List.from(json["comment"].map((x) => Comment.fromJson(x))) .toList(), ); Map toJson() => { "id_qna": idQna, "id_lesson": idLesson, "sender": sender, "username": username, "quest": quest, "foto_profile": fotoProfile, "date": date, "comment": List.from(comment.map((x) => x)), }; } /// Class untuk response tambah class QnaPostModel { QnaPostModel({ this.status, this.error, required this.data, }); final int? status; final bool? error; final DataPostQna data; factory QnaPostModel.fromJson(Map json) => QnaPostModel( status: json["status"], error: json["error"], data: DataPostQna.fromJson(json["data"]), ); Map toJson() => { "status": status, "error": error, "data": data.toJson(), }; } class DataPostQna { DataPostQna({this.sender, this.quest, this.idCourse}); final String? sender; final String? quest; final String? idCourse; factory DataPostQna.fromJson(Map json) => DataPostQna( sender: json["sender"], quest: json["quest"], idCourse: json["id_course"], ); Map toJson() => { "messages": sender, "quest": quest, "id_course": idCourse, }; }