# Geography, Address, Delivery, and Currency Models

## Localization storage

Every `name_ar/en`, `code_ar/en`, and `description_ar/en` pair below is one JSON attribute on the model (for example, `name`), backed by a JSON column and listed in `$translatable`. Filament edits each locale with `->translatable()`.

## `Currency` → `currencies`

Fields: `id`, `name_ar/en`, `code_ar/en`, `is_primary`, `round_prices`, `is_active`, `status`, admin attribution, timestamps.

Relationships: exchangeRates, countries, cities, zones, orders; creating/updating admins.

Renames: `is_main → is_primary`, `allow_price_rounded → round_prices`, bilingual suffixes, `active → is_active`, legacy publication `status → status`. Enforce exactly one primary currency.

## `CurrencyExchangeRate` → `currency_exchange_rates`

Fields: `id`, `currency_id`, decimal(18,8) `rate`, `effective_at`, status/audit/timestamps. Belongs to currency/admins. Index `currency_id + effective_at`.

Renames: `day_exchange → rate`, `add_date → effective_at`.

## `Country` → `countries`

Fields: `id`, unique `iso3_code`, unique nullable `iso2_code`, `dial_code`, `name_ar/en`, `flag_path`, nullable continent/demographics, nullable `currency_id`, `has_own_currency`, `has_drivers`, registration/address visibility, decimal `delivery_fee`, `has_free_delivery`, status/audit/timestamps.

Relationships: belongs to currency; has many cities, addresses, users, languages.

Renames: `Code/Code2 → iso3_code/iso2_code`, `country_dial_code → dial_code`, `title_* → name_*`, `flag → flag_path`, `show_app_register/add_addresse → is_registration_available/is_address_available`, `delivery_fees/free → delivery_fee/has_free_delivery`, `has_currency → has_own_currency`.

## `City` → `cities`

Fields: `id`, `country_id`, nullable `currency_id`, `legacy_governorate_id`, `ministry_code`, `name_ar/en`, `district_name`, population/map fields, delivery/availability/status/audit/timestamps.

Relationships: belongs to country/currency; has many zones, addresses, users.

Renames: `CountryCode → country_id` via ISO lookup, `ye_gov_id → legacy_governorate_id`, `title_* → name_*`, `District → district_name`, `google_maps_glatlng/zoom → map_coordinates/map_zoom`.

## `Zone` → `zones`

Fields: `id`, `city_id`, nullable `currency_id`, `legacy_city_id`, `ministry_code`, `name_ar/en`, nullable decimal coordinates, map zoom, delivery/availability/status/audit/timestamps.

Relationships: belongs to city/currency; has many addresses/users.

Renames: `title_* → name_*`, `city_id_old → legacy_city_id`, `maps_zoom → map_zoom`.

## `CountryLanguage` → `country_languages`

Fields: `country_id`, `language`, `is_official`, decimal percentage, status/audit/timestamps. Belongs to country. Composite key `country_id + language`.

Renames: `CountryCode → country_id`, `Language → language`, `IsOfficial → is_official`, `Percentage → percentage`.

## `AddressType` → `address_types`

Fields: `id`, `sort_order`, `name_ar/en`, `description_ar/en`, `image_path`, status/audit/timestamps. Has many addresses.

Renames: `order_view → sort_order`, `title_* → name_*`, `image → image_path`.

## `Address` → `addresses`

Fields: `id`, `user_id`, `country_id`, `city_id`, nullable `zone_id`, `address_type_id`, mobile/description, nullable coordinate decimals, `is_active`, nullable `updated_by_admin_id`, request metadata, timestamps.

Relationships: belongs to user, country, city, zone, type and updating admin; has many orders for history.

Renames: `area_id → zone_id`, `address_type → address_type_id`, `status → is_active`, `date → created_at`, `modify_admin_id/date → updated_by_admin_id/updated_at`, `ipaddress → ip_address`.

## `DeliveryTime` → `delivery_times`

Fields: `id`, nullable self `parent_id`, `sort_order`, `type`, nullable `starts_at/ends_at`, `name_ar/en`, `icon_path`, status/audit/timestamps.

Relationships: parent, children, orders.

Renames: `order_view → sort_order`, `from_time/to_time → starts_at/ends_at`, `title_* → name_*`, `icon → icon_path`. Drop derived `isHasSub` and `levelParent`.

## No-model views

The singular country/city and governorate/district tables are SQL compatibility views. Use Country, City, and Zone models only.
