Product model
TheProduct model (app/Models/Product.php) is the central catalog entity.
Key fields
Relationships
Dual-strategy media architecture
Products use a hybrid approach to balance catalog performance against rich gallery support.- Strategy 1: image_path column
- Strategy 2: Spatie Medialibrary
The primary product thumbnail is stored in the This is O(1) — no additional queries. Used on catalog grids, search results, and cart items.
image_path column. The image_url accessor returns a fully-qualified public URL using Laravel’s Storage facade.Blurhash
Theblur_hash column stores a compact LQIP (Low Quality Image Placeholder) string generated asynchronously by the blurhash media job. The React frontend renders this as a colored placeholder while the real image loads.
Menu sections
TheMenuSection model groups products into named sections (e.g., “Entradas”, “Platos Fuertes”, “Bebidas”). Sections are ordered by sort_order.
Tenant::getPublicMenuStructure() returns null for non-pro tenants:
Modifier groups and options
Modifier groups allow customers to customize a product at checkout (e.g., “Size: Small / Medium / Large”, “Add-ons: Extra Cheese”).$product->modifierGroups()->orderBy('sort_order').
Product option groups
Product option groups handle variant-style selections (e.g., color, size) via theProductOptionGroup and ProductOption models, ordered by sort_order.
Impulse buy cross-selling
Products flagged withis_impulse_buy = true appear as suggestions at checkout. The platform uses a performant ID-fetch-and-shuffle pattern to avoid ORDER BY RAND() at scale:
Business owner view vs API view
- Business owner view
- API view
The tenant panel (Filament at
/app) provides full product management via ProductResource. The workspace at /workspace/products exposes a React CRUD interface backed by ProductController.Routes available at /workspace/products:Inventory management
Products withmanage_stock = true track stock via stock_quantity and low_stock_threshold. When stock falls below the threshold, a broadcast event notifies the tenant dashboard in real time.
| Field | Type | Purpose |
|---|---|---|
manage_stock | boolean | Enables inventory tracking |
stock_quantity | integer | Current units available |
low_stock_threshold | integer | Triggers low-stock alert |
allow_backorders | boolean | Allow orders beyond stock |
stock_status | StockStatus enum | in_stock, out_of_stock, backorder |