import 'package:flutter/foundation.dart'; /// Model representing a taxi service with contact and location information @immutable class TaxiModel { final String id; final String name; final String phone; final String corregimiento; final String shift; final bool isActive; final DateTime createdAt; final DateTime updatedAt; const TaxiModel({ required this.id, required this.name, required this.phone, required this.corregimiento, required this.shift, required this.isActive, required this.createdAt, required this.updatedAt, }); /// Create TaxiModel from Supabase JSON response factory TaxiModel.fromJson(Map json) { return TaxiModel( id: json['id'] as String, name: json['name'] as String, phone: json['phone'] as String, corregimiento: json['corregimiento'] as String, shift: json['shift'] as String, isActive: json['is_active'] as bool? ?? true, createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), ); } /// Convert TaxiModel to JSON for Supabase operations Map toJson() { return { 'id': id, 'name': name, 'phone': phone, 'corregimiento': corregimiento, 'shift': shift, 'is_active': isActive, 'created_at': createdAt.toIso8601String(), 'updated_at': updatedAt.toIso8601String(), }; } /// Create a copy with modified properties TaxiModel copyWith({ String? id, String? name, String? phone, String? corregimiento, String? shift, bool? isActive, DateTime? createdAt, DateTime? updatedAt, }) { return TaxiModel( id: id ?? this.id, name: name ?? this.name, phone: phone ?? this.phone, corregimiento: corregimiento ?? this.corregimiento, shift: shift ?? this.shift, isActive: isActive ?? this.isActive, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, ); } @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is TaxiModel && other.id == id; } @override int get hashCode => id.hashCode; @override String toString() { return 'TaxiModel(id: $id, name: $name, phone: $phone, corregimiento: $corregimiento, shift: $shift, isActive: $isActive)'; } } /// Model representing a user's favorite taxi @immutable class FavoriteTaxiModel { final String id; final String userId; final String taxiId; final DateTime createdAt; const FavoriteTaxiModel({ required this.id, required this.userId, required this.taxiId, required this.createdAt, }); /// Create FavoriteTaxiModel from Supabase JSON response factory FavoriteTaxiModel.fromJson(Map json) { return FavoriteTaxiModel( id: json['id'] as String, userId: json['user_id'] as String, taxiId: json['taxi_id'] as String, createdAt: DateTime.parse(json['created_at'] as String), ); } /// Convert FavoriteTaxiModel to JSON for Supabase operations Map toJson() { return { 'id': id, 'user_id': userId, 'taxi_id': taxiId, 'created_at': createdAt.toIso8601String(), }; } @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is FavoriteTaxiModel && other.id == id; } @override int get hashCode => id.hashCode; @override String toString() { return 'FavoriteTaxiModel(id: $id, userId: $userId, taxiId: $taxiId)'; } }