Illuminate\Database\Query\Builder::addNestedWhereQuery PHP Method

addNestedWhereQuery() public method

Add another query builder as a nested where to the query builder.
public addNestedWhereQuery ( Builder | static $query, string $boolean = 'and' )
$query Builder | static
$boolean string
    public function addNestedWhereQuery($query, $boolean = 'and')
    {
        if (count($query->wheres)) {
            $type = 'Nested';
            $this->wheres[] = compact('type', 'query', 'boolean');
            $this->addBinding($query->getBindings(), 'where');
        }
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Add a basic where clause to the query.
  *
  * @param  string  $column
  * @param  string  $operator
  * @param  mixed   $value
  * @param  string  $boolean
  * @return \Illuminate\Database\Eloquent\Builder|static
  */
 public function where($column, $operator = null, $value = null, $boolean = 'and')
 {
     if ($column instanceof Closure) {
         $query = $this->model->newQuery();
         call_user_func($column, $query);
         $this->query->addNestedWhereQuery($query->getQuery(), $boolean);
     } else {
         $this->query->where($column, $operator, $value, $boolean);
     }
     return $this;
 }
All Usage Examples Of Illuminate\Database\Query\Builder::addNestedWhereQuery