Skip to content
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

Undefined property: Illuminate\\Database\\Eloquent\\Relations\\HasMany::$orWhere #50172

Closed
streamingsystems opened this issue Feb 21, 2024 · 4 comments · Fixed by #50176
Closed
Labels

Comments

@streamingsystems
Copy link

Laravel Version

10.45.0

PHP Version

8.3.3

Database Driver & Version

mysql

Description

Hi,

I upgrade each week to the latest Laravel. When I upgraded today from 10.44.0 to 10.45.0 and I am now getting this stack trace.

2024-02-20 21:29:08] web.ERROR: Undefined property: Illuminate\Database\Eloquent\Relations\HasMany::$orWhere {"exception":"[object] (ErrorException(code: 0): Undefined property: Illuminate\Database\Eloquent\Relations\HasMany::$orWhere at

The Line in my code looks like this:

->when(!$series, function ($query) {
$query->notSeries()->orWhere->book()->orWhere->speaker();
})

This has worked for a long time (years) and stopped today.

I looked through the fixes that went into 10.45.0 and can't seem to determine what might have caused it.

I just reverted back to 10.44.0 and it's working again so I am sure it's in 10.45.0.

Thanks!

Steps To Reproduce

n/a (not sure how to reproduce short of the code I wrote above)

@nuernbergerA
Copy link
Contributor

This is caused by #50124 we already pinned v10.44 due to massive failures.

@nuernbergerA
Copy link
Contributor

added a PR with a currently failing test that passes with v10.44 and below #50176

@crynobone crynobone added the bug label Feb 21, 2024
@siarheipashkevich
Copy link
Contributor

The same issue also

@devnicolas1
Copy link

devnicolas1 commented Feb 21, 2024

Not sure if exactly related, but I'm also having an issue caused by #50124 in a Laravel Nova project.

Being more specific, the trait Illuminate\Support\Traits\Tappable that was added to the Relation class seems to cause a type hint problem with our custom Nova filters and a few other Nova methods. For example:

App\Nova\Resource::indexQuery(): Return value must be of type Illuminate\Database\Eloquent\Builder, Staudenmeir\EloquentHasManyDeep\HasManyDeep returned {"userId":2,"exception":"[object] (TypeError(code: 0): App\\Nova\\Resource::indexQuery(): Return value must be of type Illuminate\\Database\\Eloquent\\Builder, Staudenmeir\\EloquentHasManyDeep\\HasManyDeep returned at /srv/app/Nova/Resource.php:31)

The indexQuery method came directly from Nova docs and wasn't even modified by us.

App\Nova\Filters\Subscriptions\Type::apply(): Return value must be of type Illuminate\Database\Eloquent\Builder, Illuminate\Database\Eloquent\Relations\HasManyThrough returned {"userId":2,"exception":"[object] (TypeError(code: 0): App\\Nova\\Filters\\Subscriptions\\Type::apply(): Return value must be of type Illuminate\\Database\\Eloquent\\Builder, Illuminate\\Database\\Eloquent\\Relations\\HasManyThrough returned at /srv/app/Nova/Filters/Subscriptions/Type.php:32)

This one is a custom filter we have. It is defined using Nova 3 way of creating filters, and although our project is currently using Nova 4, it worked just fine until Laravel 10.45.

Again, removing the trait Tappable from Relation seems to solve the issue.

I'm probably opening a new issue for this if it doesn't get fixed in 10.46, but until that, I'll at least add these details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants