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

[10.x] Allow to pass Arrayable to whereIn and whereNotIn queries #905

Open
wants to merge 2 commits into
base: 10.x
Choose a base branch
from

Conversation

Joel-Jensen
Copy link

@Joel-Jensen Joel-Jensen commented Jan 30, 2025

One annoyance that we often have and where the ecosystem doesn't feel cohesive throughout, is when adding search to an existing query and it suddenly stops working because of a collection being passed to whereInor whereNotIn.

$users = collect([1]);

Existing query without Scout

User::whereIn("id", $users)->get(); 
// Returns 1 user

Adding Scout...

Before change

User::search("Taylor")->whereIn("id", $users)->get(); 
// TypeError  Laravel\Scout\Builder::whereIn(): Argument #2 ($values) must be of type array, Illuminate\Support\Collection given

After change

User::search("Taylor")->whereIn("id", $users)->get(); 
// Returns 1 user

I don't like that I had to remove a type declaration, but by looking at other classes (1, 2) this seems to be the way to go.

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.

1 participant