You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, you can define a dynamic relation using Relation::resolveRelationUsing(), but this doesn't work when a relation is already defined in the model class.
I'm not certain the best approach on this as if the function already exists, it would return the existing method from the model, but perhaps if there was some resolver check inside of the Relation classes, it could return the defined dynamic relationship instead of the existing one. I think this could be accomplished by implementing a check in each of the relationship functions to return from the relationResolvers first before anything.
This would become a breaking change since it could break the code for anyone already dynamically defining relationships, so the recommendation is for Laravel 10.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently, you can define a dynamic relation using
Relation::resolveRelationUsing()
, but this doesn't work when a relation is already defined in the model class.I'm not certain the best approach on this as if the function already exists, it would return the existing method from the model, but perhaps if there was some resolver check inside of the Relation classes, it could return the defined dynamic relationship instead of the existing one. I think this could be accomplished by implementing a check in each of the relationship functions to return from the relationResolvers first before anything.
This would become a breaking change since it could break the code for anyone already dynamically defining relationships, so the recommendation is for Laravel 10.
Beta Was this translation helpful? Give feedback.
All reactions