Level 52
-
Sale Model
- Needs a
items()relationship ($this->hasManyThrough)
- Needs a
- SaleItem Model
- Item Model
Review relationships and you'll be set to go.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
these are my three tables
-SALES -id -details
-SALES_ITEMS -sale_id -item_id
-ITEMS -id -name
After a sale done will push sale details to SALES table and push items of that sale to SALES_ITEMS table with 'id' from SALES table.item name are in ITEMS table..so i need to retrive datas from all three combined..like below:- {sales{[id:1, Details:..., sale_items:{[id:1 Item_id:1 item:{[id:1 name:item-name]}]}]}}
How to setup model and how to use that in controler? Ps: dont mind json typos..posting from mobile
Please or to participate in this conversation.