I have 3 Tables:
Companies
Products
Images
Now, Companies and Products are Many to Many relationship.
Meaning, 1 company can have many products and a product can belong to multiple companies. So, I have a pivot table called companies_products with pivot or additional columns such as: price, discount, status, etc...
Note: Products table represents only common-data, that is, it does not have price, status, etc... product is only complete with pivot cols because that is how it makes a product unique to each company.
Everything is fine until here. Now because pivot table represents a unique product cols for each company. I also want to attach product-images table to this pivot table. Which means, my structure would be each pivot row hasMany product_images.
But in Laravel I guess pivot tables does not have a model, it is not encouraged to do so. Then how to achieve has-Many with pivot table?
Or any better solution to structure my tables or data?
In summary,
I have 1 companies table and 1 products table (unique).
companies create final product by adding extra data and images(array). I can handle extra data which goes as a pivot cols but not images (which in this case is array of images. I cant have 1 to many directly at products table level because each company adds a product with extra data to it.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2roFoFC
via IFTTT
Aucun commentaire:
Enregistrer un commentaire