Update Saqel Platform: 2026-09-05 23:24:49
This commit is contained in:
@@ -144,3 +144,157 @@ class TeacherPayoutRequestModel {
|
||||
required this.status,
|
||||
});
|
||||
}
|
||||
|
||||
class TeacherProfileModel {
|
||||
final int id;
|
||||
final String uuid;
|
||||
final String name;
|
||||
final String specialization;
|
||||
final String schoolName;
|
||||
final List<String> gradesTaught;
|
||||
final String bio;
|
||||
final double rating;
|
||||
final int studentsCount;
|
||||
final int lessonsCount;
|
||||
|
||||
const TeacherProfileModel({
|
||||
required this.id,
|
||||
required this.uuid,
|
||||
required this.name,
|
||||
required this.specialization,
|
||||
required this.schoolName,
|
||||
required this.gradesTaught,
|
||||
required this.bio,
|
||||
this.rating = 4.9,
|
||||
this.studentsCount = 42,
|
||||
this.lessonsCount = 28,
|
||||
});
|
||||
|
||||
factory TeacherProfileModel.fromJson(Map<String, dynamic> json) {
|
||||
final user = json['user'] as Map<String, dynamic>? ?? {};
|
||||
final profile = json['profile'] as Map<String, dynamic>? ?? {};
|
||||
|
||||
List<String> grades = [];
|
||||
if (profile['grades_taught'] is List) {
|
||||
grades = (profile['grades_taught'] as List).map((e) => e.toString()).toList();
|
||||
} else if (profile['grades_taught'] is String) {
|
||||
grades = [profile['grades_taught'].toString()];
|
||||
}
|
||||
if (grades.isEmpty) {
|
||||
grades = ['الصف العاشر الأساسي', 'الأول ثانوي العلمي'];
|
||||
}
|
||||
|
||||
return TeacherProfileModel(
|
||||
id: user['id'] is int ? user['id'] : 1,
|
||||
uuid: user['uuid']?.toString() ?? '',
|
||||
name: user['full_name']?.toString() ?? 'الأستاذ المعتمد',
|
||||
specialization: profile['specialization']?.toString() ?? 'الفيزياء',
|
||||
schoolName: profile['school_name']?.toString() ?? 'مدرسة الملك عبد الله الثاني للتميز',
|
||||
gradesTaught: grades,
|
||||
bio: profile['bio']?.toString() ?? 'معلم معتمد في منصة صَقِل',
|
||||
rating: 4.9,
|
||||
studentsCount: 42,
|
||||
lessonsCount: 28,
|
||||
);
|
||||
}
|
||||
|
||||
TeacherProfileModel copyWith({
|
||||
String? name,
|
||||
String? specialization,
|
||||
String? schoolName,
|
||||
List<String>? gradesTaught,
|
||||
String? bio,
|
||||
}) {
|
||||
return TeacherProfileModel(
|
||||
id: id,
|
||||
uuid: uuid,
|
||||
name: name ?? this.name,
|
||||
specialization: specialization ?? this.specialization,
|
||||
schoolName: schoolName ?? this.schoolName,
|
||||
gradesTaught: gradesTaught ?? this.gradesTaught,
|
||||
bio: bio ?? this.bio,
|
||||
rating: rating,
|
||||
studentsCount: studentsCount,
|
||||
lessonsCount: lessonsCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChatConversationModel {
|
||||
final int userId;
|
||||
final String userUuid;
|
||||
final String fullName;
|
||||
final String role;
|
||||
final String? specialization;
|
||||
final String lastMessage;
|
||||
final String lastMessageType;
|
||||
final String? lastMessageAt;
|
||||
final int unreadCount;
|
||||
|
||||
const ChatConversationModel({
|
||||
required this.userId,
|
||||
required this.userUuid,
|
||||
required this.fullName,
|
||||
required this.role,
|
||||
this.specialization,
|
||||
required this.lastMessage,
|
||||
required this.lastMessageType,
|
||||
this.lastMessageAt,
|
||||
this.unreadCount = 0,
|
||||
});
|
||||
|
||||
factory ChatConversationModel.fromJson(Map<String, dynamic> json) {
|
||||
return ChatConversationModel(
|
||||
userId: json['user_id'] is int ? json['user_id'] : int.tryParse(json['user_id']?.toString() ?? '0') ?? 0,
|
||||
userUuid: json['user_uuid']?.toString() ?? '',
|
||||
fullName: json['full_name']?.toString() ?? 'طالب صَقِل',
|
||||
role: json['role']?.toString() ?? 'student',
|
||||
specialization: json['specialization']?.toString(),
|
||||
lastMessage: json['last_message']?.toString() ?? '',
|
||||
lastMessageType: json['last_message_type']?.toString() ?? 'text',
|
||||
lastMessageAt: json['last_message_at']?.toString(),
|
||||
unreadCount: json['unread_count'] is int ? json['unread_count'] : 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChatMessageModel {
|
||||
final int id;
|
||||
final String uuid;
|
||||
final bool isMine;
|
||||
final int senderId;
|
||||
final int receiverId;
|
||||
final String message;
|
||||
final String messageType; // 'text', 'voice', 'image', 'file'
|
||||
final String? mediaUrl;
|
||||
final bool isRead;
|
||||
final String createdAt;
|
||||
|
||||
const ChatMessageModel({
|
||||
required this.id,
|
||||
required this.uuid,
|
||||
required this.isMine,
|
||||
required this.senderId,
|
||||
required this.receiverId,
|
||||
required this.message,
|
||||
required this.messageType,
|
||||
this.mediaUrl,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory ChatMessageModel.fromJson(Map<String, dynamic> json) {
|
||||
return ChatMessageModel(
|
||||
id: json['id'] is int ? json['id'] : int.tryParse(json['id']?.toString() ?? '0') ?? 0,
|
||||
uuid: json['uuid']?.toString() ?? '',
|
||||
isMine: json['is_mine'] ?? false,
|
||||
senderId: json['sender_id'] is int ? json['sender_id'] : int.tryParse(json['sender_id']?.toString() ?? '0') ?? 0,
|
||||
receiverId: json['receiver_id'] is int ? json['receiver_id'] : int.tryParse(json['receiver_id']?.toString() ?? '0') ?? 0,
|
||||
message: json['message']?.toString() ?? '',
|
||||
messageType: json['message_type']?.toString() ?? 'text',
|
||||
mediaUrl: json['media_url']?.toString(),
|
||||
isRead: json['is_read'] ?? false,
|
||||
createdAt: json['created_at']?.toString() ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user