|
13 | 13 | - [Where Clauses](#where-clauses)
|
14 | 14 | - [Or Where Clauses](#or-where-clauses)
|
15 | 15 | - [Where Not Clauses](#where-not-clauses)
|
16 |
| - - [Where Any / All Clauses](#where-any-all-clauses) |
| 16 | + - [Where Any / All / None Clauses](#where-any-all-none-clauses) |
17 | 17 | - [JSON Where Clauses](#json-where-clauses)
|
18 | 18 | - [Additional Where Clauses](#additional-where-clauses)
|
19 | 19 | - [Logical Grouping](#logical-grouping)
|
@@ -502,8 +502,8 @@ The `whereNot` and `orWhereNot` methods may be used to negate a given group of q
|
502 | 502 | })
|
503 | 503 | ->get();
|
504 | 504 |
|
505 |
| -<a name="where-any-all-clauses"></a> |
506 |
| -### Where Any / All Clauses |
| 505 | +<a name="where-any-all-none-clauses"></a> |
| 506 | +### Where Any / All / None Clauses |
507 | 507 |
|
508 | 508 | 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:
|
509 | 509 |
|
@@ -549,6 +549,29 @@ WHERE published = true AND (
|
549 | 549 | )
|
550 | 550 | ```
|
551 | 551 |
|
| 552 | +The `whereNone` method may be used to retrieve records where none of the given columns match a given constraint: |
| 553 | + |
| 554 | + $posts = DB::table('albums') |
| 555 | + ->where('published', true) |
| 556 | + ->whereNone([ |
| 557 | + 'title', |
| 558 | + 'lyrics', |
| 559 | + 'tags', |
| 560 | + ], 'like', '%explicit%') |
| 561 | + ->get(); |
| 562 | + |
| 563 | +The query above will result in the following SQL: |
| 564 | + |
| 565 | +```sql |
| 566 | +SELECT * |
| 567 | +FROM albums |
| 568 | +WHERE published = true AND NOT ( |
| 569 | + title LIKE '%explicit%' OR |
| 570 | + lyrics LIKE '%explicit%' OR |
| 571 | + tags LIKE '%explicit%' |
| 572 | +) |
| 573 | +``` |
| 574 | + |
552 | 575 | <a name="json-where-clauses"></a>
|
553 | 576 | ### JSON Where Clauses
|
554 | 577 |
|
|
0 commit comments