Skip to content

Commit c9dfe78

Browse files
authored
Add documentation for the whereNone method (#9786)
1 parent b874bc0 commit c9dfe78

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

queries.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- [Where Clauses](#where-clauses)
1414
- [Or Where Clauses](#or-where-clauses)
1515
- [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)
1717
- [JSON Where Clauses](#json-where-clauses)
1818
- [Additional Where Clauses](#additional-where-clauses)
1919
- [Logical Grouping](#logical-grouping)
@@ -502,8 +502,8 @@ The `whereNot` and `orWhereNot` methods may be used to negate a given group of q
502502
})
503503
->get();
504504

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
507507

508508
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:
509509

@@ -549,6 +549,29 @@ WHERE published = true AND (
549549
)
550550
```
551551

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+
552575
<a name="json-where-clauses"></a>
553576
### JSON Where Clauses
554577

0 commit comments

Comments
 (0)