@@ -752,7 +752,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
752
752
);
753
753
754
754
if (! $ value instanceof Expression) {
755
- $ this ->addBinding (is_array ( $ value ) ? head ($ value ) : $ value , 'where ' );
755
+ $ this ->addBinding ($ this -> flattenValue ($ value ), 'where ' );
756
756
}
757
757
758
758
return $ this ;
@@ -1121,7 +1121,7 @@ public function whereBetween($column, array $values, $boolean = 'and', $not = fa
1121
1121
1122
1122
$ this ->wheres [] = compact ('type ' , 'column ' , 'values ' , 'boolean ' , 'not ' );
1123
1123
1124
- $ this ->addBinding (array_slice ($ this ->cleanBindings ($ values ), 0 , 2 ), 'where ' );
1124
+ $ this ->addBinding (array_slice ($ this ->cleanBindings (Arr:: flatten ( $ values) ), 0 , 2 ), 'where ' );
1125
1125
1126
1126
return $ this ;
1127
1127
}
@@ -1244,7 +1244,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
1244
1244
$ value , $ operator , func_num_args () === 2
1245
1245
);
1246
1246
1247
- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1247
+ $ value = $ this -> flattenValue ($ value );
1248
1248
1249
1249
if ($ value instanceof DateTimeInterface) {
1250
1250
$ value = $ value ->format ('Y-m-d ' );
@@ -1285,7 +1285,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
1285
1285
$ value , $ operator , func_num_args () === 2
1286
1286
);
1287
1287
1288
- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1288
+ $ value = $ this -> flattenValue ($ value );
1289
1289
1290
1290
if ($ value instanceof DateTimeInterface) {
1291
1291
$ value = $ value ->format ('H:i:s ' );
@@ -1326,7 +1326,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
1326
1326
$ value , $ operator , func_num_args () === 2
1327
1327
);
1328
1328
1329
- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1329
+ $ value = $ this -> flattenValue ($ value );
1330
1330
1331
1331
if ($ value instanceof DateTimeInterface) {
1332
1332
$ value = $ value ->format ('d ' );
@@ -1371,7 +1371,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
1371
1371
$ value , $ operator , func_num_args () === 2
1372
1372
);
1373
1373
1374
- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1374
+ $ value = $ this -> flattenValue ($ value );
1375
1375
1376
1376
if ($ value instanceof DateTimeInterface) {
1377
1377
$ value = $ value ->format ('m ' );
@@ -1416,7 +1416,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
1416
1416
$ value , $ operator , func_num_args () === 2
1417
1417
);
1418
1418
1419
- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1419
+ $ value = $ this -> flattenValue ($ value );
1420
1420
1421
1421
if ($ value instanceof DateTimeInterface) {
1422
1422
$ value = $ value ->format ('Y ' );
@@ -1726,7 +1726,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a
1726
1726
$ this ->wheres [] = compact ('type ' , 'column ' , 'operator ' , 'value ' , 'boolean ' );
1727
1727
1728
1728
if (! $ value instanceof Expression) {
1729
- $ this ->addBinding ((int ) $ value );
1729
+ $ this ->addBinding ((int ) $ this -> flattenValue ( $ value) );
1730
1730
}
1731
1731
1732
1732
return $ this ;
@@ -1875,7 +1875,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
1875
1875
$ this ->havings [] = compact ('type ' , 'column ' , 'operator ' , 'value ' , 'boolean ' );
1876
1876
1877
1877
if (! $ value instanceof Expression) {
1878
- $ this ->addBinding (is_array ( $ value ) ? head ($ value ) : $ value , 'having ' );
1878
+ $ this ->addBinding ($ this -> flattenValue ($ value ), 'having ' );
1879
1879
}
1880
1880
1881
1881
return $ this ;
@@ -1913,7 +1913,7 @@ public function havingBetween($column, array $values, $boolean = 'and', $not = f
1913
1913
1914
1914
$ this ->havings [] = compact ('type ' , 'column ' , 'values ' , 'boolean ' , 'not ' );
1915
1915
1916
- $ this ->addBinding ($ this ->cleanBindings ($ values ), 'having ' );
1916
+ $ this ->addBinding (array_slice ( $ this ->cleanBindings (Arr:: flatten ( $ values)), 0 , 2 ), 'having ' );
1917
1917
1918
1918
return $ this ;
1919
1919
}
@@ -3178,6 +3178,17 @@ public function cleanBindings(array $bindings)
3178
3178
}));
3179
3179
}
3180
3180
3181
+ /**
3182
+ * Get a scalar type value from an unknown type of input.
3183
+ *
3184
+ * @param mixed $value
3185
+ * @return mixed
3186
+ */
3187
+ protected function flattenValue ($ value )
3188
+ {
3189
+ return is_array ($ value ) ? head (Arr::flatten ($ value )) : $ value ;
3190
+ }
3191
+
3181
3192
/**
3182
3193
* Get the default key name of the table.
3183
3194
*
0 commit comments