# Model Schema Review Index

The model design is split into related domain files so each group can be reviewed and approved before implementation.

1. [Identity and access](docs/model-schema/01-identity-and-access.md)
2. [Geography, addresses, delivery, and currency](docs/model-schema/02-geography-and-currency.md)
3. [Catalogue and provider availability](docs/model-schema/03-catalogue.md)
4. [Orders, delivery, payments, and ratings](docs/model-schema/04-orders-and-payments.md)
5. [Coupons, wallet, and loyalty](docs/model-schema/05-coupons-wallet-loyalty.md)
6. [Content, notifications, and configuration](docs/model-schema/06-content-notifications-settings.md)
7. [Legacy table disposition and generation checklist](docs/model-schema/07-legacy-disposition.md)
8. [Localized field convention](docs/model-schema/08-localization-convention.md)

## Review workflow

Review and approve the files in order. Implementation starts only after the relevant group is approved. Each file records canonical models/tables, fields and types, relationships, constraints, explicit `legacy_name → canonical_name` references, and whether each model is populated, optional, consolidated, or omitted.

## Shared conventions

- Tables use plural `snake_case`; models use singular `StudlyCase`.
- Foreign keys use `_id`, are indexed, and have explicit delete behavior.
- Unix timestamps become Laravel datetimes.
- Money, percentages, coordinates, and rates use fixed decimals.
- Legacy bilingual pairs are stored as one JSON column, not as separate language columns. In the model notes, `name_ar/en`, `title_ar/en`, `description_ar/en`, and similar notation means the canonical field is `name`, `title`, or `description` with a value such as `{\"ar\": \"...\", \"en\": \"...\"}`.
- Every model with localized attributes uses `Spatie\Translatable\HasTranslations` and declares the JSON attributes in its `$translatable` list. Filament forms use the `->translatable()` field macro supplied by `alareqi/filament-translatable-fields`.
- Legacy `_arabic/_english` columns are migrated with an explicit map: `*_arabic → {attribute}.ar` and `*_english → {attribute}.en`; the old columns are not copied into the new schema.
- Legacy `active=0` becomes canonical `is_active=true`.
- JSON snapshots remain JSON to preserve history.
- Backed enums replace magic values after meanings are confirmed.
- Each importer includes an explicit rename/transformation map.
