34 lines
1006 B
Dart
34 lines
1006 B
Dart
|
|
// lib/features/notifications/models/notification_model.dart
|
||
|
|
|
||
|
|
class NotificationModel {
|
||
|
|
final int id;
|
||
|
|
final String title;
|
||
|
|
final String message;
|
||
|
|
final String type; // event, promo, system, booking
|
||
|
|
bool isRead;
|
||
|
|
final DateTime createdAt;
|
||
|
|
final String? actionUrl;
|
||
|
|
|
||
|
|
NotificationModel({
|
||
|
|
required this.id,
|
||
|
|
required this.title,
|
||
|
|
required this.message,
|
||
|
|
this.type = 'system',
|
||
|
|
this.isRead = false,
|
||
|
|
required this.createdAt,
|
||
|
|
this.actionUrl,
|
||
|
|
});
|
||
|
|
|
||
|
|
factory NotificationModel.fromJson(Map<String, dynamic> json) {
|
||
|
|
return NotificationModel(
|
||
|
|
id: (json['id'] as num?)?.toInt() ?? 0,
|
||
|
|
title: json['title'] as String? ?? '',
|
||
|
|
message: json['message'] as String? ?? '',
|
||
|
|
type: json['notification_type'] as String? ?? json['type'] as String? ?? 'system',
|
||
|
|
isRead: (json['is_read'] as bool?) ?? false,
|
||
|
|
createdAt: DateTime.tryParse(json['created_at'] as String? ?? '') ?? DateTime.now(),
|
||
|
|
actionUrl: json['action_url'] as String?,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|