Overview
The Ecom platform provides a flexible categorization system with hierarchical categories and brand management to organize products effectively. Categories support nested structures, multi-language translations, and visual assets.Hierarchical Categories
Unlimited nested category levels with parent-child relationships
Multi-Language Support
Category names and descriptions in multiple languages
Brand Management
Organize products by brand with logo support
Visual Assets
Cover images, icons, and banners for categories
Category Model
TheCategory model provides a hierarchical structure for organizing products.
Category Relationships
Parent-Child Structure
Parent-Child Structure
Categories support unlimited nesting levels:Location:
~/workspace/source/app/Models/Category.php:43-56This structure allows you to create deep category hierarchies like:- Electronics
- Computers
- Laptops
- Desktops
- Mobile Phones
- Smartphones
- Feature Phones
- Computers
Product Relationship
Product Relationship
Categories have a many-to-many relationship with products:Location:
~/workspace/source/app/Models/Category.php:30-33This allows products to belong to multiple categories simultaneously, enabling flexible product organization and cross-category listings.Visual Assets
Visual Assets
Categories support multiple image types for different display contexts:Location:
~/workspace/source/app/Models/Category.php:22-37Image Types:- Cover Image: Main category image for listings
- Icon: Small icon for navigation and menus
- Banner: Large banner for category landing pages
Attributes & Size Charts
Attributes & Size Charts
Categories can have associated attributes and size guides:Location:
~/workspace/source/app/Models/Category.php:58-66Attributes define product characteristics (like color, size, material) that vary by category.Category Translations
Categories support multi-language content through theCategoryTranslation model:
~/workspace/source/app/Models/Category.php:12-20
Eager Loading
Category translations are automatically loaded to improve performance:~/workspace/source/app/Models/Category.php:10
Usage Example
Brand Model
TheBrand model allows products to be organized by manufacturer or brand.
Brand Structure
~/workspace/source/app/Models/Brand.php:8-29
Brand Features
Multi-Language Names
Brand names translated for different locales
Brand Logos
Upload and display brand logos
Product Association
Products linked to brands via relationship
Eager Loading
Translations automatically loaded for performance
Product-Category Association
In theProductController, categories are managed during product creation and updates.
Category Selection During Creation
~/workspace/source/app/Http/Controllers/ProductController.php:176-186
This loads only parent categories (where parent_id = 0) along with their nested children for physical products (digital = 0).
Attaching Categories to Products
~/workspace/source/app/Http/Controllers/ProductController.php:215
The attach() method creates records in the product_categories pivot table, allowing a product to belong to multiple categories.
Updating Category Association
~/workspace/source/app/Http/Controllers/ProductController.php:324-326
The sync() method updates the category associations, removing old ones and adding new ones as specified.
Category Types
Physical vs Digital
Categories are separated by product type:Classified Products
Categories can also be used for classified ads:~/workspace/source/app/Models/Category.php:39-41
Category Filtering in Products
TheProductController uses categories for filtering during product editing:
~/workspace/source/app/Http/Controllers/ProductController.php:265-281
Brand-Product Filtering
Products can be retrieved by brand:~/workspace/source/app/Http/Controllers/ProductController.php:467-471
Implementation Examples
Loading Nested Categories
Loading Nested Categories
Category with Products Count
Category with Products Count
Brand with Logo
Brand with Logo
Database Structure
Category Fields
id- Primary keyparent_id- Reference to parent categorylevel- Category hierarchy levelname- Default nameslug- URL-friendly identifierbanner- Banner image IDicon- Icon image IDcover_image- Cover image IDdigital- Physical (0) or Digital (1) categoryfeatured- Featured category flagorder- Display order
Brand Fields
id- Primary keyname- Default brand namelogo- Logo image IDslug- URL-friendly identifiermeta_title- SEO meta titlemeta_description- SEO meta description
Related Resources
Product Management
Learn how products use categories and brands
Multi-Language
Understand the translation system