-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Can not execute has/whereHas on MorphTo relation. #25724
Comments
Thanks @staudenmeir |
They are support if someone does not understand how |
Revert to Laravel <5.6.35 and replace |
It worked in L5.5, after upgrading to 5.7 it doesn't work
With different model for example L5.7 with disabled exception.
Example of production code: Search comments for entities. foreach (Comments::all() as $name) {
$builder->orWhere(function (Builder $builder) use ($has, $name, $search) {
/* @var Model $entity */
$entity = Comments::resolve($name);
$builder->where('entity_type', $entity->getMorphClass());
$builder->getModel()->setAttribute('entity_type', $entity->getMorphClass());
$has->call($builder, 'entity', '>=', 1, 'and',
function (Builder $builder) use ($search) {
Nova::resourceForModel($builder->getModel())::applySearch($builder, $search);
}
]);
});
} |
How is the |
|
Laravel 5.8.27 will add |
Description:
Can not execute has/whereHas on MorphTo relation.
It throws RuntimeException('has() and whereHas() do not support MorphTo relationships.')
It happened after #25337
Steps To Reproduce:
Search all entities where exists $relatedEntity.
The text was updated successfully, but these errors were encountered: