Skip to content

[12.x] Use associative arrays with where clauses #10538

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

Conversation

kevinb1989
Copy link
Contributor

I find passing an array to a where clause super neat, particularly when we have lots of where conditions.

I believe passing an associate array is way more common than passing one with 3-part elements. So I add an example for the former.

@@ -538,9 +538,14 @@ $users = DB::table('users')
->get();
```

You may also pass an array of conditions to the `where` function. Each element of the array should be an array containing the three arguments typically passed to the `where` method:
You may also pass an array of conditions to the `where` function. That array can be an associative one. Or each element of the array could be an array itself containing the three arguments typically passed to the `where` method:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You may also pass an array of conditions to the `where` function. That array can be an associative one. Or each element of the array could be an array itself containing the three arguments typically passed to the `where` method:
You may also pass an array of conditions to the `where` function. That array can be an associative one, or each element of the array could be an array itself containing the three arguments typically passed to the `where` method:

@taylorotwell
Copy link
Member

I think it's fine as is.

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.

3 participants