I'm trying to create some dynamic relation-builder. It utilises a class called StructureFactory
aka SF
which is responsible for keeping model-formatting algorithms, relations, bindings, and so on...
As of now, the factory is capable of being kept inside the mother-model as a static array alongside other models' factories. No problems here, all cool.
There's one uncool thing though, if there are multiple distinctive factories for a single child model, only the last one will remain, definitely because they share the same classname.
AND, there's no way I could pass down these factories as instance-based non-static fields, these models are obviously re-created for each relation they instantiate.
I need a way to pass non-static fields down to every related instance of a given model instance. Consider $lemon->colour
, I want every instance created by eager-loading during $lemon->get()
to maintain the colour
field as $lemon
did. Further thanks for your assistance.
I barely thought a code piece will be necessary or even sufficient, so I didn't put any. Tell me if any mechanism would be playing a part in your understanding of the situation.