Skip to content

Commit 89fbfaf

Browse files
committed
JT feedback
1 parent eb5f12a commit 89fbfaf

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

docs/includes/query-builder/QueryBuilderTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,30 @@ public function testWhereIn(): void
148148
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $result);
149149
}
150150

151-
public function testWhereDate(): void
151+
public function testWhereCarbon(): void
152152
{
153153
// begin query where date
154154
$result = DB::connection('mongodb')
155155
->table('movies')
156-
->where('released', Carbon::create(2010, 1, 15, 0, 0, 0, 'UTC'))
156+
->where('released', Carbon::create(2010, 1, 15))
157157
->get();
158158
// end query where date
159159

160160
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $result);
161161
}
162162

163+
public function testWhereDate(): void
164+
{
165+
// begin query whereDate string
166+
$result = DB::connection('mongodb')
167+
->table('movies')
168+
->whereDate('released', '2010-1-15')
169+
->get();
170+
// end query whereDate string
171+
172+
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $result);
173+
}
174+
163175
public function testLike(): void
164176
{
165177
// begin query like

docs/query-builder.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,18 @@ is January 15, 2010, specified in a ``Carbon`` object:
369369
objects. The {+odm-short+} applies the default timezone when performing
370370
this conversion.
371371

372+
If you want to represent a date as a string in your query filter
373+
rather than as a ``Carbon`` object, use the ``whereDate()`` query
374+
builder method. The following example retrieves documents from
375+
the ``movies`` collection in which the ``released`` value
376+
is January 15, 2010 and specifies the date as a string:
377+
378+
.. literalinclude:: /includes/query-builder/QueryBuilderTest.php
379+
:language: php
380+
:dedent:
381+
:start-after: begin query whereDate string
382+
:end-before: end query whereDate string
383+
372384
.. _laravel-query-builder-pattern:
373385

374386
Text Pattern Match Example

0 commit comments

Comments
 (0)