Skip to content

Commit 500ae9b

Browse files
authored
DOCSP-42818: wherelike and wherenotlike docs (#3114)
* DOCSP-42818: wherelike and wherenotlike docs * heading fix * move section * wip * add cross link
1 parent f24b464 commit 500ae9b

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

docs/includes/query-builder/QueryBuilderTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,18 @@ public function testWhereRegex(): void
374374
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $result);
375375
}
376376

377+
public function testWhereLike(): void
378+
{
379+
// begin query whereLike
380+
$result = DB::connection('mongodb')
381+
->table('movies')
382+
->whereLike('title', 'Start%', true)
383+
->get();
384+
// end query whereLike
385+
386+
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $result);
387+
}
388+
377389
public function testWhereRaw(): void
378390
{
379391
// begin query raw

docs/includes/query-builder/sample_mflix.movies.json

+5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@
148148
}
149149
}
150150
},
151+
{
152+
"runtime": 120,
153+
"directors": ["Alan Pakula"],
154+
"title": "Starting Over"
155+
},
151156
{
152157
"genres": ["Crime", "Drama"],
153158
"runtime": 119,

docs/query-builder.txt

+36
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,42 @@ wildcard characters:
381381
...
382382
]
383383

384+
whereLike() and whereNotLike() Methods
385+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
386+
387+
The following methods provide the same functionality as using the
388+
:ref:`like <laravel-query-builder-pattern>` query operator to match
389+
patterns:
390+
391+
- ``whereLike()``: Matches a specified pattern. By default, this method
392+
performs a case-insensitive match. You can enable case-sensitivity by
393+
passing ``true`` as the last parameter to the method.
394+
- ``whereNotLike()``: Matches documents in which the field
395+
value does not contain the specified string pattern.
396+
397+
The following example shows how to use the ``whereLike()`` method to
398+
match documents in which the ``title`` field has a value that matches the
399+
pattern ``'Start%'`` with case-sensitivity enabled:
400+
401+
.. io-code-block::
402+
:copyable: true
403+
404+
.. input:: /includes/query-builder/QueryBuilderTest.php
405+
:language: php
406+
:dedent:
407+
:start-after: begin query whereLike
408+
:end-before: end query whereLike
409+
410+
.. output::
411+
:language: json
412+
:visible: false
413+
414+
[
415+
{ "title": "Start-Up", ... },
416+
{ "title": "Start the Revolution Without Me", ... },
417+
...
418+
]
419+
384420
.. _laravel-query-builder-distinct:
385421

386422
Retrieve Distinct Values

0 commit comments

Comments
 (0)