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

[9.x] Remove static return types #41276

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

browner12
Copy link
Contributor

I would definitely like a second set of eyes on this, but I'm pretty sure these methods will only return instances of the Eloquent or Query Builder. It was a little difficult to find how these methods are called, but it's in the \Illuminate\Database\Eloquent\SoftDeletingScope.

The reason I came across this was that I was trying to select trashed Eloquent models on a specific database connection.

$user = User::withTrashed()->on($connection);

This doesn't actually work, but the IDE thinks it's okay, because it sees withTrashed() returning static, which is \App\User which extends the \Illuminate\Database\Eloquent\Model, which does have the on() method.

In reality, it returns the \Illuminate\Database\Eloquent\Builder which does not have the on() method.

these methods only return the Builder
@browner12
Copy link
Contributor Author

originally from commit 7b91285

@taylorotwell taylorotwell merged commit ecec6ca into laravel:9.x Mar 1, 2022
@browner12
Copy link
Contributor Author

On a related note, any ideas on how to get all models, including trashed, on a specific connection?

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

Successfully merging this pull request may close these issues.

2 participants