I have 3 tables:
customer
:fields: id, name
item
:fields: id, name
customer_items
:fields: customer_id, item_id, qty
Customer
and Item
have their separate Models as we would expect.
Question: How would I relate these two(Customer and Item) without having a pivot model.
I want to directly get customer items using $customer->items
instead of doing $customer->customerItem->items
which I find unnecessary since I don't want to track customerItems & customer by item.
Also, I cannot directly use customer_items
table for Item
model as I might need to retrieve all items in its controller.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire