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
Am getting an Illuminate\Database\ClassMorphViolationException because I have Relation::enforceMorphMap for some classes. Kindly confirm if this is the desired behavior
Hi @SamuelMwangiW, I think this is expected. The tokens and notifications relationships on your User model are both MorphMany relationships, so you'd need to specify a morph map for them to work in this scenario. You would get the same exception if you tried to access those relations anywhere else in your application.
If you're not using these relationships, you may consider removing the HasApiTokens and Notifiable traits from the model.
I've confirmed that the exception is not thrown if an "unmapped" model doesn't have any polymorphic relations, so I wouldn't consider this a bug.
Description:
Thanks a lot for the amazing work @jessarcher on #43156 .
Am getting an
Illuminate\Database\ClassMorphViolationException
because I have Relation::enforceMorphMap for some classes. Kindly confirm if this is the desired behaviorIt otherwise works perfectly fine when the enforceMorphMap is commented out:
Steps To Reproduce:
Relation::enforceMorphMap(['model'=>'App\Models\Model'])
in theboot
method ofAppServiceProvider
and omitting to add\App\Models\User
artisan model:show User
The text was updated successfully, but these errors were encountered: