Skip to content

Commit

Permalink
Add documentation for the whereNone method (#9786)
Browse files Browse the repository at this point in the history
  • Loading branch information
einar-hansen authored Aug 1, 2024
1 parent b874bc0 commit c9dfe78
Showing 1 changed file with 26 additions and 3 deletions.
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

0 comments on commit c9dfe78

Please sign in to comment.