import 'package:objectbox/objectbox.dart'; import 'package:intl/intl.dart'; import 'package:mobdr/objectbox.g.dart'; import 'package:mobdr/service/shared_prefs.dart'; // ignore_for_file: public_member_api_docs @Entity() class Photo { // specify the id @Id() int id = 0; int id_visite; int id_photo_typologie; String image_name; DateTime date_photo; int id_photo_mp4; int photo_privee; int photo_principale; String tags; int uploaded; Photo( {this.id = 0, required this.id_visite, required this.id_photo_typologie, required this.image_name, this.id_photo_mp4 = 0, this.photo_privee = 0, this.photo_principale = 0, this.tags = '', DateTime? date_photo, this.uploaded = 0}) : date_photo = date_photo ?? DateTime.now(); static String? _photosDir = SharedPrefs().photosDir; String getImage() { if (_photosDir == null) { throw Exception('Photos directory not initialized'); } return '$_photosDir/$image_name'; } String get dateFormat => DateFormat('dd.MM.yyyy hh:mm:ss').format(date_photo); Photo copyWith({ int? id, int? id_visite, int? id_photo_typologie, String? image, String? image_name, DateTime? date_photo, int? id_photo_mp4, int? photo_privee, int? photo_principale, String? tags, int? uploaded, }) { return Photo( id: id ?? this.id, id_visite: id_visite ?? this.id_visite, id_photo_typologie: id_photo_typologie ?? this.id_photo_typologie, image_name: image_name ?? this.image_name, date_photo: date_photo ?? this.date_photo, id_photo_mp4: id_photo_mp4 ?? this.id_photo_mp4, photo_privee: photo_privee ?? this.photo_privee, photo_principale: photo_principale ?? this.photo_principale, tags: tags ?? this.tags, uploaded: uploaded ?? this.uploaded, ); } /* Photo.fromJson(Map json) : id_visite = json['id_visite'], id_photo_typologie = json['id_photo_typologie'], image = json['image']; */ }