# Catalogue and Provider Availability Models

## Localization storage

Every bilingual field below is one JSON attribute (`name`, `description`, or `content`) backed by a JSON column and declared in the model’s `$translatable` list. The Filament field uses `->translatable()`; legacy Arabic/English columns are imported into the `ar` and `en` JSON keys.

## `Category` → `categories`

Fields: `id`, nullable self `parent_id`, `sort_order`, `is_home_visible`, `name_ar/en`, `description_ar/en`, `icon_path`, status/audit/timestamps.

Relationships: parent, children, and products.

Renames: `order_view → sort_order`, `in_home → is_home_visible` (`1=yes`, `2=no`), `title_* → name_*`, `icon → icon_path`. Drop derived `isHasSub`.

## `Brand` → `brands`

Fields: `id`, `sort_order`, bilingual name/description, `image_path`, optional counters, status/audit/timestamps. Has many products.

Renames: `order_view → sort_order`, `image → image_path`, `visits_arabic/english → views_ar/en` only if retained.

## `Product` → `products`

Fields: `id`, `category_id`, nullable `brand_id`, `sort_order`, `is_home_visible`, `is_featured`, `name_ar/en`, decimal `base_price`, decimal/integer `stock_quantity` after unit confirmation, bilingual description, `main_image_path`, counters, status/audit/timestamps.

Relationships: belongs to category/brand/admins; has many images, variants, provider products, favorites, order items; belongs to many related products.

Renames: `order_view → sort_order`, `in_home → is_home_visible`, `chosen_product → is_featured`, `price → base_price`, `quantity → stock_quantity`, `image → main_image_path`, `visits/orders → views_count/orders_count`.

## `ProductImage` → `product_images`

Fields: `id`, `product_id`, `path`, `is_primary`, new `sort_order`, nullable `uploaded_by_user_id`, timestamps. Belongs to product/user.

Renames: `image → path`, `is_main → is_primary`, `user_id → uploaded_by_user_id`, `date → created_at`.

## `VariantSection` → `variant_sections` (empty)

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

Renames: `platform_products_variants_sections → variant_sections`, `order_view → sort_order`, `image → image_path`.

## `ProductVariant` → `product_variants` (empty)

Fields: `id`, `product_id`, `variant_section_id`, `sort_order`, bilingual name/description, decimal `price` or `price_adjustment` after confirmation, `image_path`, status/audit/timestamps.

Relationships: belongs to product/variant section; has many order items.

Renames: `type_variant_id → variant_section_id`, `order_view → sort_order`, `image → image_path`.

## `RelatedProduct` → `related_products` (empty)

Fields: `id`, `product_id`, `related_product_id`, nullable `created_by_user_id`, timestamps. Unique pair; prevent self-reference.

Renames: `platform_products_else → related_products`, `product_else_id → related_product_id`, `user_id → created_by_user_id`, `date → created_at`.

## `ProviderProduct` → `provider_products` (empty)

Fields: `id`, `provider_id`, `product_id`, decimal price/percentage, `is_available`, `is_admin_enabled`, nullable `updated_by_admin_id`, timestamps. Belongs to provider User/product/admin. Unique provider/product.

Renames: `user_id → provider_id`, `status → is_available`, `admin_active → is_admin_enabled`, `admin_modify_user_id/date → updated_by_admin_id/updated_at`.

## `ProviderSection` → `provider_sections` (empty)

Fields: `provider_id`, `section_id`, `is_active`, timestamps; composite unique key. Belongs to provider User and section.

Renames: `user_id → provider_id`, `status → is_active`.

## `Favorite` → `favorites`

Fields: `id`, `user_id`, `product_id`, `created_at`. Belongs to user/product. Unique user/product.

Renames: remove `active` through idempotent add/delete; `date → created_at`.

Do not model `platform_users_provider_products_all_collection_info`; it is a derived counter table.
