@@ -491,7 +491,7 @@ public function joinWhere($table, $first, $operator, $second, $type = 'inner')
491491 /**
492492 * Add a subquery join clause to the query.
493493 *
494- * @param \Closure|\Illuminate\Database\Query\Builder|string $query
494+ * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder| string $query
495495 * @param string $as
496496 * @param \Closure|string $first
497497 * @param string|null $operator
@@ -544,7 +544,7 @@ public function leftJoinWhere($table, $first, $operator, $second)
544544 /**
545545 * Add a subquery left join to the query.
546546 *
547- * @param \Closure|\Illuminate\Database\Query\Builder|string $query
547+ * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder| string $query
548548 * @param string $as
549549 * @param \Closure|string $first
550550 * @param string|null $operator
@@ -587,7 +587,7 @@ public function rightJoinWhere($table, $first, $operator, $second)
587587 /**
588588 * Add a subquery right join to the query.
589589 *
590- * @param \Closure|\Illuminate\Database\Query\Builder|string $query
590+ * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder| string $query
591591 * @param string $as
592592 * @param \Closure|string $first
593593 * @param string|null $operator
@@ -752,7 +752,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
752752 );
753753
754754 if (! $ value instanceof Expression) {
755- $ this ->addBinding (is_array ( $ value ) ? head ($ value ) : $ value , 'where ' );
755+ $ this ->addBinding ($ this -> flattenValue ($ value ), 'where ' );
756756 }
757757
758758 return $ this ;
@@ -1121,7 +1121,7 @@ public function whereBetween($column, array $values, $boolean = 'and', $not = fa
11211121
11221122 $ this ->wheres [] = compact ('type ' , 'column ' , 'values ' , 'boolean ' , 'not ' );
11231123
1124- $ this ->addBinding (array_slice ($ this ->cleanBindings ($ values ), 0 , 2 ), 'where ' );
1124+ $ this ->addBinding (array_slice ($ this ->cleanBindings (Arr:: flatten ( $ values) ), 0 , 2 ), 'where ' );
11251125
11261126 return $ this ;
11271127 }
@@ -1244,7 +1244,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
12441244 $ value , $ operator , func_num_args () === 2
12451245 );
12461246
1247- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1247+ $ value = $ this -> flattenValue ($ value );
12481248
12491249 if ($ value instanceof DateTimeInterface) {
12501250 $ value = $ value ->format ('Y-m-d ' );
@@ -1285,7 +1285,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
12851285 $ value , $ operator , func_num_args () === 2
12861286 );
12871287
1288- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1288+ $ value = $ this -> flattenValue ($ value );
12891289
12901290 if ($ value instanceof DateTimeInterface) {
12911291 $ value = $ value ->format ('H:i:s ' );
@@ -1326,7 +1326,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
13261326 $ value , $ operator , func_num_args () === 2
13271327 );
13281328
1329- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1329+ $ value = $ this -> flattenValue ($ value );
13301330
13311331 if ($ value instanceof DateTimeInterface) {
13321332 $ value = $ value ->format ('d ' );
@@ -1371,7 +1371,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
13711371 $ value , $ operator , func_num_args () === 2
13721372 );
13731373
1374- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1374+ $ value = $ this -> flattenValue ($ value );
13751375
13761376 if ($ value instanceof DateTimeInterface) {
13771377 $ value = $ value ->format ('m ' );
@@ -1416,7 +1416,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
14161416 $ value , $ operator , func_num_args () === 2
14171417 );
14181418
1419- $ value = is_array ( $ value ) ? head ($ value ) : $ value ;
1419+ $ value = $ this -> flattenValue ($ value );
14201420
14211421 if ($ value instanceof DateTimeInterface) {
14221422 $ value = $ value ->format ('Y ' );
@@ -1726,7 +1726,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a
17261726 $ this ->wheres [] = compact ('type ' , 'column ' , 'operator ' , 'value ' , 'boolean ' );
17271727
17281728 if (! $ value instanceof Expression) {
1729- $ this ->addBinding ((int ) $ value );
1729+ $ this ->addBinding ((int ) $ this -> flattenValue ( $ value) );
17301730 }
17311731
17321732 return $ this ;
@@ -1875,7 +1875,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
18751875 $ this ->havings [] = compact ('type ' , 'column ' , 'operator ' , 'value ' , 'boolean ' );
18761876
18771877 if (! $ value instanceof Expression) {
1878- $ this ->addBinding (is_array ( $ value ) ? head ($ value ) : $ value , 'having ' );
1878+ $ this ->addBinding ($ this -> flattenValue ($ value ), 'having ' );
18791879 }
18801880
18811881 return $ this ;
@@ -1913,7 +1913,7 @@ public function havingBetween($column, array $values, $boolean = 'and', $not = f
19131913
19141914 $ this ->havings [] = compact ('type ' , 'column ' , 'values ' , 'boolean ' , 'not ' );
19151915
1916- $ this ->addBinding ($ this ->cleanBindings ($ values ), 'having ' );
1916+ $ this ->addBinding (array_slice ( $ this ->cleanBindings (Arr:: flatten ( $ values)), 0 , 2 ), 'having ' );
19171917
19181918 return $ this ;
19191919 }
@@ -3178,6 +3178,17 @@ public function cleanBindings(array $bindings)
31783178 }));
31793179 }
31803180
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+
31813192 /**
31823193 * Get the default key name of the table.
31833194 *
0 commit comments