New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incomplete Relation::morphMap() support #29181
Comments
Ping @staudenmeir |
We decided against supporting aliases in
|
The part I was missing is that the In my case I'm extending a package model and rewrite the alias in a local ASP, but I can always do Thank you! |
So Is there any solution for this issue? how use custom morph type in |
@Reund0 You pass the class instead of the alias: App\Comment::whereHasMorph(
'commentable',
Relation::$morphMap['posts'],
...
); |
Description:
When using polymorphic relationships with custom polymorphic types,
when building queries with
hasMorph
(whereHasMorph), the custom polymorphic types are not'translated' to classes in all cases and we get
Class 'myCustomPolyType' not found
errors.As far as I can tell, the transformation from types to classes is made here
framework/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
Line 208 in 341fb54
only when
types === '*'
and I think it should be performed also when the types are specifically given.Steps To Reproduce:
whereHasMorph
condition, where you specify types, similar toThe text was updated successfully, but these errors were encountered: