Closed circulon closed 2 years ago
You'll need to use polymorphic relationships https://orm.masoniteproject.com/models#polymorphic-relationships
@josephmancuso
This is exactly what I was hoping to find was already available.
I obviously missed this in the docs previously.
Thanks heaps.
Describe the feature as you'd like to see it I have a couple of models which contain a UUID/ID (not foreign key) and a flag which denotes which Destination Model the UUID/ID is attached to.
In other ORM's I have dropped in some logic which checks the flag and then uses the correct model. Currently this logic (in masonite orm) results in a recursion error as using
self
in the decorated method to check the attribute is not possible.I'm not sure if this is a bug or a feature request or is this something that can be achieved via a lambda/function
In this example the recursion error is due to the
self.vehicle_type
in the method which calls the Model (self) to get its relations and attributes which then descends into the decoratedvehicle
method, which then gets the Model (self) relations ........is there another way to achive this kind of `flagged' logic? I'm happy to try out new logic but this seems to be the most straight forward to achieve the outcome Using a pivot table is not really suitable for this scenario.
What do we currently have to do now? Don't have any way to do this currently
Additional context Add any other context or screenshots about the feature request here.