Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 21, 2021
1 parent c6b8168 commit 006873d
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,6 @@ public function fromRaw($expression, $bindings = [])
return $this;
}

/**
* Returns scalar type value from an unknown type of input.
*
* @param mixed $value
* @return mixed
*/
protected function scalarValue($value)
{
return is_array($value) ? head(Arr::flatten($value)) : $value;
}

/**
* Creates a subquery and parse it.
*
Expand Down Expand Up @@ -709,7 +698,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
);

if (! $value instanceof Expression) {
$this->addBinding($this->scalarValue($value), 'where');
$this->addBinding($this->flattenValue($value), 'where');
}

return $this;
Expand Down Expand Up @@ -1122,7 +1111,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = $this->scalarValue($value);
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('Y-m-d');
Expand Down Expand Up @@ -1163,7 +1152,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = $this->scalarValue($value);
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('H:i:s');
Expand Down Expand Up @@ -1204,7 +1193,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = $this->scalarValue($value);
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('d');
Expand Down Expand Up @@ -1249,7 +1238,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = $this->scalarValue($value);
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('m');
Expand Down Expand Up @@ -1294,7 +1283,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = $this->scalarValue($value);
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('Y');
Expand Down Expand Up @@ -1604,7 +1593,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a
$this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');

if (! $value instanceof Expression) {
$this->addBinding((int) $this->scalarValue($value));
$this->addBinding((int) $this->flattenValue($value));
}

return $this;
Expand Down Expand Up @@ -1753,7 +1742,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');

if (! $value instanceof Expression) {
$this->addBinding($this->scalarValue($value), 'having');
$this->addBinding($this->flattenValue($value), 'having');
}

return $this;
Expand Down Expand Up @@ -2969,6 +2958,17 @@ protected function cleanBindings(array $bindings)
}));
}

/**
* Get a scalar type value from an unknown type of input.
*
* @param mixed $value
* @return mixed
*/
protected function flattenValue($value)
{
return is_array($value) ? head(Arr::flatten($value)) : $value;
}

/**
* Get the default key name of the table.
*
Expand Down

0 comments on commit 006873d

Please sign in to comment.