---
tags: [products, model]
module: Products
---

# [Model]Product

## Connections
[[_Products]] · [[[Model]WarehouseProduct]] · [[[Model]Category]] · [[[Model]Unit]] · [[[Observer]Observers]] · [[[Service]ProductServices]] · [[[Repo]Repositories]] · [[[Cross]CrossModuleDependencies]]

## Source
`Modules/Products/Models/Product.php` · `Modules/Products/Models/ProductRecipe.php` · `Modules/Products/Models/ProductQuantity.php`

## Responsibilities
- Central product entity: PRODUCT, RECIPE, SERVICE, EXPENSE
- Multi-account linking: inventory, selling, purchasing, additional_cost accounts
- Recipe composition via ProductRecipe (product → ingredient WarehouseProducts)
- ProductQuantity: legacy audit trail of quantity changes (bill_id, change direction)
- CascadeSoftDeletes, AuditableTrait, UsesTenantConnection

## Key Relationships
| Relation | Type | Target |
|---|---|---|
| category | belongsTo | [[[Model]Category]] |
| unit | belongsTo | [[[Model]Unit]] |
| warehouseProducts | hasMany | [[[Model]WarehouseProduct]] |
| inventoryAccount | belongsTo | [[[Model]Account]] (Accounting) |
| sellingAccount | belongsTo | [[[Model]Account]] (Accounting) |
| purchasingAccount | belongsTo | [[[Model]Account]] (Accounting) |
| tax | belongsTo | Tax (Settings) |
| productRecipe | hasMany | ProductRecipe (ingredient list) |
| recipeIncludedProducts | hasManyThrough | Product via ProductRecipe |

## ProductRecipe
Composition: `product_id` (ingredient) + `warehouse_product_id` + quantity + cost
Table: `product_recipe` — soft deleted with parent

## Key Methods
- `getIdentifierPrefix()` / `getNextIdentifierSequence()` — auto-ID generation
- `updateTotalProductCosts()` — recalculate cost from warehouse data
- `enableWarehouseAttributes()` — appends warehouse-specific computed attributes
