I have the following four models:
- App\Chain
- App\Shop
- App\ProductGroup
- App\Product
I am wondering if it is possible to use a single pivot table with the following columns in order to store many to many relationships between any of the models:
Table name: owner_entity_child_entity
- id
- owner_entity_type (all models, except for chain)
- owner_entity_id
- child_entity_type (all models, except for product)
- child_entity_id
So that when, for example, I query $chain->products, I would be able to retrieve all the products that are not only directly linked to the $chain itself, but also to the shops and product groups that are linked to the chain.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2EZATdc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire