Allow more than just WHERE clauses on eager load constraints.
This commit is contained in:
parent
2d4fa7217a
commit
39df69fdc1
|
@ -395,7 +395,7 @@ public function or_where_not_null($column)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a nested where condition to the query.
|
* Add nested constraints to the query.
|
||||||
*
|
*
|
||||||
* @param Closure $callback
|
* @param Closure $callback
|
||||||
* @param string $connector
|
* @param string $connector
|
||||||
|
@ -403,24 +403,7 @@ public function or_where_not_null($column)
|
||||||
*/
|
*/
|
||||||
public function where_nested($callback, $connector = 'AND')
|
public function where_nested($callback, $connector = 'AND')
|
||||||
{
|
{
|
||||||
$type = 'where_nested';
|
call_user_func($callback, $this);
|
||||||
|
|
||||||
// To handle a nested where statement, we will actually instantiate a new
|
|
||||||
// Query instance and run the callback over that instance, which will
|
|
||||||
// allow the developer to have a fresh query instance
|
|
||||||
$query = new Query($this->connection, $this->grammar, $this->from);
|
|
||||||
|
|
||||||
call_user_func($callback, $query);
|
|
||||||
|
|
||||||
// Once the callback has been run on the query, we will store the nested
|
|
||||||
// query instance on the where clause array so that it's passed to the
|
|
||||||
// query's query grammar instance when building.
|
|
||||||
if ($query->wheres !== null)
|
|
||||||
{
|
|
||||||
$this->wheres[] = compact('type', 'query', 'connector');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->bindings = array_merge($this->bindings, $query->bindings);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue