Skip to content

Commit

Permalink
fix orWhere
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 22, 2018
1 parent a432d9e commit e5042e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
*/
public function orWhere($column, $operator = null, $value = null)
{
list($value, $operator) = $this->query->prepareValueAndOperator(
$value, $operator, func_num_args() == 2
);

return $this->where($column, $operator, $value, 'or');
}

Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ protected function addArrayOfWheres($column, $boolean, $method = 'where')
*
* @throws \InvalidArgumentException
*/
protected function prepareValueAndOperator($value, $operator, $useDefault = false)
public function prepareValueAndOperator($value, $operator, $useDefault = false)
{
if ($useDefault) {
return [$operator, '='];
Expand Down Expand Up @@ -631,6 +631,10 @@ protected function invalidOperator($operator)
*/
public function orWhere($column, $operator = null, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
$value, $operator, func_num_args() == 2
);

return $this->where($column, $operator, $value, 'or');
}

Expand Down

0 comments on commit e5042e1

Please sign in to comment.