Answer the question
In order to leave comments, you need to log in
Model hierarchy in Laravel?
Good day, %username%!
Look what a thing. The answer to the question described below probably lies on the surface, but something cannot be formulated in any way.
We have an abstract factory that produces products. Absolutely all products have such a property as an article . In addition, all products are divided into two classes :
Answer the question
In order to leave comments, you need to log in
In order to describe these relationships in Laravel, we can create one migration of the product table, describe in it all the possible properties that are mentioned in the types (class, type, article, width, height, material, whether it is fireproof, whether it is varnished), after why create models of the necessary products, preserving the inheritance we need, but the question is how, for example, to specify for the model, when working with a common table (where all products are stored in general), return only those that have, for example, class = (int) 2?
Product (nested set), Attribute (refer to different product levels), Value
I think it's worth adapting the ECS pattern, and more specifically Entity + Component. I think it will fit perfectly.
PS Initially, it was developed for gamedev, where there is an archer, an archer-mage, an archer-mage-with-a-spear, etc. At the same time, there are no restrictions on the characteristics and their relationships.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question