Skip to content

Commit e2c3023

Browse files
committed
(+) fix whereDate operator for day
(+) fix whereDate operator for month and year
1 parent d37cdf6 commit e2c3023

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Query/Builder.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,31 +1166,33 @@ protected function compileWhereDate(array $where)
11661166

11671167
$date = Carbon::parse($value);
11681168

1169-
$operator = $operator === '=' ? '$eq' : $this->conversion[$operator];
1169+
$operator = $this->conversion[$operator];
1170+
$operatorDay = $operator === '=' ? '$eq' : $operator;
1171+
$operatorMonthYear = $operator === '=' ? '$eq' : (in_array($operator, ['$gt', '$lt']) ? $operator . 'e' : $operator);
11701172

11711173
return [
11721174
'$expr' => [
11731175
'$and' => [
11741176
[
1175-
$operator => [
1177+
$operatorDay => [
11761178
[
11771179
'$dayOfMonth' => '$'.$column
11781180
],
11791181
$date->day
11801182
],
11811183
],
11821184
[
1183-
$operator => [
1185+
$operatorMonthYear => [
11841186
[
11851187
'$month' => '$'.$column
11861188
],
11871189
$date->month
11881190
],
11891191
],
11901192
[
1191-
$operator => [
1193+
$operatorMonthYear => [
11921194
[
1193-
'$month' => '$'.$column
1195+
'$year' => '$'.$column
11941196
],
11951197
$date->year
11961198
],

0 commit comments

Comments
 (0)