Skip to content

Commit

Permalink
Remove 'whereMultiple' method
Browse files Browse the repository at this point in the history
  • Loading branch information
musiermoore committed Mar 4, 2024
1 parent 1244223 commit ed28513
Showing 1 changed file with 19 additions and 44 deletions.
63 changes: 19 additions & 44 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,17 @@ public function orWhereFullText($columns, $value, array $options = [])
*/
public function whereAll($columns, $operator = null, $value = null, $boolean = 'and')
{
return $this->whereMultiple($columns, $operator, $value, 'and', $boolean);
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

$this->whereNested(function ($query) use ($columns, $operator, $value) {
foreach ($columns as $column) {
$query->where($column, $operator, $value, 'and');
}
}, $boolean);

return $this;
}

/**
Expand Down Expand Up @@ -2135,67 +2145,32 @@ public function orWhereAll($columns, $operator = null, $value = null)
* @return $this
*/
public function whereAny($columns, $operator = null, $value = null, $boolean = 'and')
{
return $this->whereMultiple($columns, $operator, $value, 'or', $boolean);
}

/**
* Add an "or where" clause to the query for each passed column with the same value
* to check if any of passed columns matches the value.
*
* @param string[] $columns
* @param string $operator
* @param mixed $value
* @return $this
*/
public function orWhereAny($columns, $operator = null, $value = null)
{
return $this->whereAny($columns, $operator, $value, 'or');
}

/**
* Add a "where" clause to the query for each passed column with the same value.
*
* @param string[] $columns
* @param string $operator
* @param mixed $value
* @param string $columnsBoolean Boolean type between columns
* (column1 = 'foo' or column2 = 'foo')
* or
* (column1 = 'bar' and column2 = 'bar')
* @param string $boolean
* @return $this
*/
private function whereMultiple($columns, $operator = null, $value = null, $columnsBoolean = 'and', $boolean = 'and')
{
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, empty($value) && $this->invalidOperator($operator)
$value, $operator, func_num_args() === 2
);

$this->whereNested(function ($query) use ($columns, $operator, $value, $columnsBoolean) {
$this->whereNested(function ($query) use ($columns, $operator, $value) {
foreach ($columns as $column) {
$query->where($column, $operator, $value, $columnsBoolean);
$query->where($column, $operator, $value, 'or');
}
}, $boolean);

return $this;
}

/**
* Add an "or where" clause to the query for each passed column with the same value.
* Add an "or where" clause to the query for each passed column with the same value
* to check if any of passed columns matches the value.
*
* @param string[] $columns
* @param string $operator
* @param array $value
* @param string $columnsBoolean Boolean type between columns
* (column1 = 'foo' or column2 = 'foo')
* or
* (column1 = 'bar' and column2 = 'bar')
* @param mixed $value
* @return $this
*/
public function orWhereMultiple($columns, $operator = null, $value = null, $columnsBoolean = 'or')
public function orWhereAny($columns, $operator = null, $value = null)
{
return $this->whereMultiple($columns, $operator, $value, $columnsBoolean, 'or');
return $this->whereAny($columns, $operator, $value, 'or');
}

/**
Expand Down

0 comments on commit ed28513

Please sign in to comment.