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

Add documentation for the whereNone method #9786

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- [Where Clauses](#where-clauses)
- [Or Where Clauses](#or-where-clauses)
- [Where Not Clauses](#where-not-clauses)
- [Where Any / All Clauses](#where-any-all-clauses)
- [Where Any / All / None Clauses](#where-any-all-none-clauses)
- [JSON Where Clauses](#json-where-clauses)
- [Additional Where Clauses](#additional-where-clauses)
- [Logical Grouping](#logical-grouping)
Expand Down Expand Up @@ -502,8 +502,8 @@ The `whereNot` and `orWhereNot` methods may be used to negate a given group of q
})
->get();

<a name="where-any-all-clauses"></a>
### Where Any / All Clauses
<a name="where-any-all-none-clauses"></a>
### Where Any / All / None Clauses

Sometimes you may need to apply the same query constraints to multiple columns. For example, you may want to retrieve all records where any columns in a given list are `LIKE` a given value. You may accomplish this using the `whereAny` method:

Expand Down Expand Up @@ -549,6 +549,29 @@ WHERE published = true AND (
)
```

The `whereNone` method may be used to retrieve records where none of the given columns match a given constraint:

$posts = DB::table('albums')
->where('published', true)
->whereNone([
'title',
'lyrics',
'tags',
], 'like', '%explicit%')
->get();

The query above will result in the following SQL:

```sql
SELECT *
FROM albums
WHERE published = true AND NOT (
title LIKE '%explicit%' OR
lyrics LIKE '%explicit%' OR
tags LIKE '%explicit%'
)
```

<a name="json-where-clauses"></a>
### JSON Where Clauses

Expand Down