# Entity Relationship Diagram ## Entities ### BusinessType (`App\Models\BusinessType`) #### Attributes: - `id` (bigint) - `name_en` (varchar) - `name_mm` (varchar) - `slug_en` (varchar) - `slug_mm` (varchar) - `description_en` (text) - `description_mm` (text) - `requires_registration` (tinyint) - `requires_tax_document` (tinyint) - `requires_identity_document` (tinyint) - `requires_business_certificate` (tinyint) - `additional_requirements` (longtext) - `is_active` (tinyint) - `sort_order` (int) - `icon` (varchar) - `color` (varchar) - `commission_rate` (decimal) - `monthly_fee` (decimal) - `transaction_fee` (decimal) - `minimum_sale_amount` (decimal) - `verification_level` (varchar) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### Cart (`App\Models\Cart`) #### Attributes: - `id` (bigint) - `user_id` (bigint) - `product_id` (bigint) - `quantity` (int) - `price` (decimal) - `product_data` (longtext) - `created_at` (timestamp) - `updated_at` (timestamp) ### Category (`App\Models\Category`) #### Attributes: - `id` (bigint) - `name_en` (varchar) - `slug_en` (varchar) - `name_mm` (varchar) - `slug_mm` (varchar) - `image` (varchar) - `description_en` (text) - `description_mm` (text) - `commission_rate` (decimal) - `parent_id` (bigint) - `_lft` (int) - `_rgt` (int) - `is_active` (tinyint) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### Commission (`App\Models\Commission`) #### Attributes: - `id` (bigint) - `order_id` (bigint) - `seller_id` (bigint) - `amount` (decimal) - `status` (enum) - `due_date` (timestamp) - `collected_at` (timestamp) - `created_at` (timestamp) - `updated_at` (timestamp) ### Delivery (`App\Models\Delivery`) #### Attributes: - `id` (bigint) - `order_id` (bigint) - `delivery_method` (enum) - `supplier_id` (bigint) - `platform_courier_id` (bigint) - `platform_delivery_fee` (decimal) - `assigned_driver_name` (varchar) - `assigned_driver_phone` (varchar) - `assigned_vehicle_type` (varchar) - `assigned_vehicle_number` (varchar) - `pickup_address` (text) - `delivery_address` (text) - `pickup_scheduled_at` (timestamp) - `picked_up_at` (timestamp) - `estimated_delivery_date` (timestamp) - `delivered_at` (timestamp) - `tracking_number` (varchar) - `carrier_name` (varchar) - `status` (enum) - `package_weight` (decimal) - `package_dimensions` (longtext) - `package_count` (int) - `delivery_proof_image` (varchar) - `recipient_name` (varchar) - `recipient_phone` (varchar) - `recipient_signature` (varchar) - `delivery_notes` (text) - `failure_reason` (text) - `actual_delivery_cost` (decimal) - `delivery_cost_paid` (tinyint) - `delivery_cost_paid_at` (timestamp) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### DeliveryArea (`App\Models\DeliveryArea`) ### DeliveryUpdate (`App\Models\DeliveryUpdate`) #### Attributes: - `id` (bigint) - `delivery_id` (bigint) - `user_id` (bigint) - `status` (varchar) - `location` (varchar) - `notes` (text) - `latitude` (decimal) - `longitude` (decimal) - `created_at` (timestamp) - `updated_at` (timestamp) ### Discount (`App\Models\Discount`) #### Attributes: - `id` (bigint) - `name` (varchar) - `code` (varchar) - `type` (enum) - `value` (decimal) - `min_order_amount` (decimal) - `max_uses` (int) - `used_count` (int) - `starts_at` (datetime) - `expires_at` (datetime) - `is_active` (tinyint) - `applicable_to` (enum) - `applicable_product_ids` (longtext) - `applicable_category_ids` (longtext) - `applicable_seller_ids` (longtext) - `max_uses_per_user` (int) - `is_one_time_use` (tinyint) - `created_by` (bigint) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### Follow (`App\Models\Follow`) #### Attributes: - `id` (bigint) - `user_id` (bigint) - `seller_id` (bigint) - `created_at` (timestamp) - `updated_at` (timestamp) ### Order (`App\Models\Order`) #### Attributes: - `id` (bigint) - `order_number` (varchar) - `buyer_id` (bigint) - `seller_id` (bigint) - `total_amount` (decimal) - `subtotal_amount` (decimal) - `shipping_fee` (decimal) - `tax_amount` (decimal) - `tax_rate` (decimal) - `commission_amount` (decimal) - `commission_rate` (decimal) - `status` (enum) - `payment_method` (enum) - `payment_status` (enum) - `shipping_address` (longtext) - `billing_address` (longtext) - `order_notes` (text) - `tracking_number` (varchar) - `shipping_carrier` (varchar) - `estimated_delivery` (timestamp) - `delivered_at` (timestamp) - `cancelled_at` (timestamp) - `refund_status` (enum) - `refund_amount` (decimal) - `refund_reason` (text) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### OrderItem (`App\Models\OrderItem`) #### Attributes: - `id` (bigint) - `order_id` (bigint) - `product_id` (bigint) - `product_name` (varchar) - `product_sku` (varchar) - `price` (decimal) - `quantity` (int) - `subtotal` (decimal) - `product_data` (longtext) - `created_at` (timestamp) - `updated_at` (timestamp) ### Product (`App\Models\Product`) #### Attributes: - `id` (bigint) - `name_en` (varchar) - `name_mm` (varchar) - `slug_en` (varchar) - `slug_mm` (varchar) - `description_en` (text) - `description_mm` (text) - `price` (decimal) - `quantity` (int) - `category_id` (bigint) - `seller_id` (bigint) - `average_rating` (decimal) - `review_count` (int) - `specifications` (longtext) - `images` (longtext) - `dimensions` (longtext) - `sku` (varchar) - `barcode` (varchar) - `brand` (varchar) - `model` (varchar) - `color` (varchar) - `material` (varchar) - `origin` (varchar) - `discount_price` (decimal) - `discount_type` (enum) - `discount_percentage` (decimal) - `sale_badge` (varchar) - `compare_at_price` (decimal) - `sale_quantity` (int) - `sale_sold` (int) - `discount_start` (date) - `discount_end` (date) - `is_on_sale` (tinyint) - `views` (int) - `sales` (int) - `is_featured` (tinyint) - `is_new` (tinyint) - `condition` (enum) - `weight_kg` (decimal) - `warranty` (varchar) - `warranty_type` (varchar) - `warranty_period` (varchar) - `warranty_conditions` (text) - `return_policy` (varchar) - `return_conditions` (text) - `shipping_details` (text) - `shipping_cost` (decimal) - `shipping_time` (varchar) - `shipping_origin` (varchar) - `customs_info` (varchar) - `hs_code` (varchar) - `min_order_unit` (varchar) - `moq` (int) - `lead_time` (varchar) - `packaging_details` (text) - `additional_info` (text) - `listed_at` (timestamp) - `approved_at` (timestamp) - `status` (enum) - `is_active` (tinyint) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### Review (`App\Models\Review`) #### Attributes: - `id` (bigint) - `user_id` (bigint) - `product_id` (bigint) - `rating` (tinyint) - `comment` (text) - `status` (enum) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### SellerProfile (`App\Models\SellerProfile`) #### Attributes: - `id` (bigint) - `user_id` (bigint) - `store_name` (varchar) - `store_slug` (varchar) - `store_description` (text) - `store_id` (varchar) - `business_type` (varchar) - `business_type_id` (bigint) - `business_registration_number` (varchar) - `certificate` (varchar) - `tax_id` (varchar) - `contact_email` (varchar) - `contact_phone` (varchar) - `website` (varchar) - `account_number` (varchar) - `social_facebook` (varchar) - `social_twitter` (varchar) - `social_instagram` (varchar) - `social_linkedin` (varchar) - `social_youtube` (varchar) - `address` (varchar) - `city` (varchar) - `state` (varchar) - `country` (varchar) - `postal_code` (varchar) - `location` (varchar) - `store_logo` (varchar) - `store_banner` (varchar) - `business_registration_document` (varchar) - `business_certificate` (varchar) - `tax_registration_document` (varchar) - `identity_document_front` (varchar) - `identity_document_back` (varchar) - `additional_documents` (longtext) - `identity_document_type` (enum) - `status` (enum) - `verification_status` (enum) - `verification_level` (enum) - `is_verified` (tinyint) - `verified_by` (bigint) - `verified_at` (timestamp) - `verification_notes` (text) - `documents_submitted` (tinyint) - `documents_submitted_at` (timestamp) - `badge_type` (varchar) - `badge_expires_at` (timestamp) - `onboarding_completed_at` (timestamp) - `document_status` (enum) - `onboarding_status` (enum) - `current_step` (varchar) - `document_rejection_reason` (text) - `admin_notes` (text) - `created_at` (timestamp) - `updated_at` (timestamp) - `deleted_at` (timestamp) ### SellerReview (`App\Models\SellerReview`) #### Attributes: - `id` (bigint) - `user_id` (bigint) - `seller_id` (bigint) - `rating` (tinyint) - `comment` (text) - `review` (text) - `status` (enum) - `deleted_at` (timestamp) - `created_at` (timestamp) - `updated_at` (timestamp) ### User (`App\Models\User`) #### Attributes: - `id` (bigint) - `name` (varchar) - `user_id` (varchar) - `email` (varchar) - `phone` (varchar) - `password` (varchar) - `type` (enum) - `address` (text) - `city` (varchar) - `state` (varchar) - `country` (varchar) - `postal_code` (varchar) - `profile_photo` (varchar) - `email_verified_at` (timestamp) - `status` (enum) - `is_active` (tinyint) - `deleted_at` (timestamp) - `remember_token` (varchar) - `created_at` (timestamp) - `updated_at` (timestamp) ### Wishlist (`App\Models\Wishlist`) #### Attributes: - `id` (bigint) - `user_id` (bigint) - `product_id` (bigint) - `created_at` (timestamp) - `updated_at` (timestamp) ## Relationships ### BusinessType Relationships - **HasMany** `sellerProfiles` to SellerProfile (Local Key: `id`, Foreign Key: `business_type_id`) ### Cart Relationships - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) - **BelongsTo** `product` to Product (Local Key: `product_id`, Foreign Key: `id`) ### Category Relationships - **BelongsTo** `parent` to Category (Local Key: `parent_id`, Foreign Key: `id`) - **HasMany** `children` to Category (Local Key: `id`, Foreign Key: `parent_id`) - **HasMany** `products` to Product (Local Key: `id`, Foreign Key: `category_id`) - **DescendantsRelation** `descendants` to Category (Local Key: ``, Foreign Key: ``) - **AncestorsRelation** `ancestors` to Category (Local Key: ``, Foreign Key: ``) ### Commission Relationships - **BelongsTo** `order` to Order (Local Key: `order_id`, Foreign Key: `id`) - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) ### Delivery Relationships - **BelongsTo** `order` to Order (Local Key: `order_id`, Foreign Key: `id`) - **BelongsTo** `supplier` to User (Local Key: `supplier_id`, Foreign Key: `id`) - **BelongsTo** `platformCourier` to User (Local Key: `platform_courier_id`, Foreign Key: `id`) - **HasMany** `deliveryUpdates` to DeliveryUpdate (Local Key: `id`, Foreign Key: `delivery_id`) ### DeliveryArea Relationships - **BelongsTo** `sellerProfile` to SellerProfile (Local Key: `seller_profile_id`, Foreign Key: `id`) - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) ### DeliveryUpdate Relationships - **BelongsTo** `delivery` to Delivery (Local Key: `delivery_id`, Foreign Key: `id`) - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) ### Discount Relationships - **BelongsTo** `creator` to User (Local Key: `created_by`, Foreign Key: `id`) - **BelongsToMany** `products` to Product (Local Key: ``, Foreign Key: ``) ### Follow Relationships - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) - **BelongsTo** `seller` to User (Local Key: `seller_id`, Foreign Key: `id`) ### Order Relationships - **BelongsTo** `buyer` to User (Local Key: `buyer_id`, Foreign Key: `id`) - **BelongsTo** `seller` to User (Local Key: `seller_id`, Foreign Key: `id`) - **HasMany** `items` to OrderItem (Local Key: `id`, Foreign Key: `order_id`) - **HasOne** `commission` to Commission (Local Key: `id`, Foreign Key: `order_id`) - **HasMany** `reviews` to Review (Local Key: `id`, Foreign Key: `order_id`) - **HasOne** `delivery` to Delivery (Local Key: `id`, Foreign Key: `order_id`) ### OrderItem Relationships - **BelongsTo** `order` to Order (Local Key: `order_id`, Foreign Key: `id`) - **BelongsTo** `product` to Product (Local Key: `product_id`, Foreign Key: `id`) ### Product Relationships - **BelongsTo** `category` to Category (Local Key: `category_id`, Foreign Key: `id`) - **BelongsTo** `seller` to User (Local Key: `seller_id`, Foreign Key: `id`) - **HasMany** `reviews` to Review (Local Key: `id`, Foreign Key: `product_id`) - **BelongsToMany** `orders` to Order (Local Key: ``, Foreign Key: ``) - **HasMany** `orderItems` to OrderItem (Local Key: `id`, Foreign Key: `product_id`) - **BelongsTo** `sellerProfile` to SellerProfile (Local Key: `seller_id`, Foreign Key: `user_id`) ### Review Relationships - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) - **BelongsTo** `product` to Product (Local Key: `product_id`, Foreign Key: `id`) - **BelongsTo** `buyer` to User (Local Key: `user_id`, Foreign Key: `id`) - **BelongsTo** `seller` to User (Local Key: `seller_id`, Foreign Key: `id`) ### SellerProfile Relationships - **BelongsTo** `businessType` to BusinessType (Local Key: `business_type_id`, Foreign Key: `id`) - **HasMany** `reviews` to SellerReview (Local Key: `id`, Foreign Key: `seller_id`) - **HasMany** `products` to Product (Local Key: `user_id`, Foreign Key: `seller_id`) - **HasMany** `orders` to Order (Local Key: `id`, Foreign Key: `seller_id`) - **HasMany** `deliveryAreas` to DeliveryArea (Local Key: `id`, Foreign Key: `seller_profile_id`) - **HasMany** `activeDeliveryAreas` to DeliveryArea (Local Key: `id`, Foreign Key: `seller_profile_id`) ### SellerReview Relationships - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) - **BelongsTo** `seller` to SellerProfile (Local Key: `seller_id`, Foreign Key: `id`) - **BelongsTo** `buyer` to User (Local Key: `user_id`, Foreign Key: `id`) ### User Relationships - **HasOne** `sellerProfile` to SellerProfile (Local Key: `id`, Foreign Key: `user_id`) - **HasMany** `reviews` to Review (Local Key: `id`, Foreign Key: `user_id`) - **HasMany** `sellerReviews` to SellerReview (Local Key: `id`, Foreign Key: `user_id`) - **HasMany** `orders` to Order (Local Key: `id`, Foreign Key: `buyer_id`) - **HasMany** `products` to Product (Local Key: `id`, Foreign Key: `user_id`) - **BelongsToMany** `wishlist` to Product (Local Key: ``, Foreign Key: ``) - **HasMany** `following` to Follow (Local Key: `id`, Foreign Key: `user_id`) - **HasMany** `followers` to Follow (Local Key: `id`, Foreign Key: `seller_id`) - **BelongsToMany** `followingSellers` to User (Local Key: ``, Foreign Key: ``) - **BelongsToMany** `followerUsers` to User (Local Key: ``, Foreign Key: ``) ### Wishlist Relationships - **BelongsTo** `user` to User (Local Key: `user_id`, Foreign Key: `id`) - **BelongsTo** `product` to Product (Local Key: `product_id`, Foreign Key: `id`)