Files
rog_app/lib/model/entry.dart
2024-09-08 21:18:45 +09:00

54 lines
1.3 KiB
Dart

// lib/models/entry.dart
import 'event.dart';
import 'team.dart';
import 'category.dart';
class Entry {
final int id;
final Team team;
final Event event;
final NewCategory category;
final DateTime? date;
final int zekkenNumber; // 新しく追加
final String owner;
bool hasParticipated;
bool hasGoaled;
Entry({
required this.id,
required this.team,
required this.event,
required this.category,
required this.date,
required this.zekkenNumber,
required this.owner,
this.hasParticipated = false,
this.hasGoaled = false,
});
factory Entry.fromJson(Map<String, dynamic> json) {
return Entry(
id: json['id'],
team: Team.fromJson(json['team']),
event: Event.fromJson(json['event']),
category: NewCategory.fromJson(json['category']),
date: json['date'] != null
? DateTime.tryParse(json['date'])
: null,
zekkenNumber: json['zekken_number'], // 新しく追加
owner: json['owner'] is Map ? json['owner']['name'] ?? '' : json['owner'] ?? '',
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'team': team.toJson(),
'event': event.toJson(),
'category': category.toJson(),
'date': date?.toIso8601String(),
'zekken_number': zekkenNumber, // 新しく追加
'owner': owner,
};
}
}