File tree Expand file tree Collapse file tree 1 file changed +34
-31
lines changed Expand file tree Collapse file tree 1 file changed +34
-31
lines changed Original file line number Diff line number Diff line change @@ -1164,42 +1164,45 @@ protected function compileWhereDate(array $where)
1164
1164
{
1165
1165
extract ($ where );
1166
1166
1167
- $ date = Carbon::parse ($ value );
1167
+ $ startOfDay = new UTCDateTime (Carbon::parse ($ value )->startOfDay ());
1168
+ $ endOfDay = new UTCDateTime (Carbon::parse ($ value )->endOfDay ());
1168
1169
1169
1170
$ operator = $ this ->conversion [$ operator ];
1170
- $ operatorDay = $ operator === '= ' ? '$eq ' : $ operator ;
1171
- $ operatorMonthYear = $ operator === '= ' ? '$eq ' : (in_array ($ operator , ['$gt ' , '$lt ' ]) ? $ operator . 'e ' : $ operator );
1172
1171
1173
- return [
1174
- '$expr ' => [
1175
- '$and ' => [
1176
- [
1177
- $ operatorDay => [
1178
- [
1179
- '$dayOfMonth ' => '$ ' .$ column
1180
- ],
1181
- $ date ->day
1182
- ],
1183
- ],
1184
- [
1185
- $ operatorMonthYear => [
1186
- [
1187
- '$month ' => '$ ' .$ column
1188
- ],
1189
- $ date ->month
1190
- ],
1191
- ],
1192
- [
1193
- $ operatorMonthYear => [
1194
- [
1195
- '$year ' => '$ ' .$ column
1196
- ],
1197
- $ date ->year
1198
- ],
1199
- ],
1172
+ return match ($ operator ) {
1173
+ '= ' => [
1174
+ $ column => [
1175
+ '$gte ' => $ startOfDay ,
1176
+ '$lte ' => $ endOfDay ,
1200
1177
],
1201
1178
],
1202
- ];
1179
+ '$ne ' => [
1180
+ $ column => [
1181
+ '$gt ' => $ endOfDay ,
1182
+ '$lt ' => $ startOfDay ,
1183
+ ],
1184
+ ],
1185
+ '$lt ' => [
1186
+ $ column => [
1187
+ '$lt ' => $ startOfDay ,
1188
+ ],
1189
+ ],
1190
+ '$gt ' => [
1191
+ $ column => [
1192
+ '$gt ' => $ endOfDay ,
1193
+ ],
1194
+ ],
1195
+ '$lte ' => [
1196
+ $ column => [
1197
+ '$lte ' => $ endOfDay ,
1198
+ ],
1199
+ ],
1200
+ '$gte ' => [
1201
+ $ column => [
1202
+ '$gte ' => $ startOfDay ,
1203
+ ],
1204
+ ],
1205
+ };
1203
1206
}
1204
1207
1205
1208
/**
You can’t perform that action at this time.
0 commit comments