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

whereExists() public method

Add an exists clause to the query.
public whereExists ( Closure $callback, string $boolean = 'and', boolean $not = false )
$callback Closure
$boolean string
$not boolean
    public function whereExists(Closure $callback, $boolean = 'and', $not = false)
    {
        $query = $this->newQuery();
        // Similar to the sub-select clause, we will create a new query instance so
        // the developer may cleanly specify the entire exists query and we will
        // compile the whole thing in the grammar and insert it into the SQL.
        call_user_func($callback, $query);
        return $this->addWhereExistsQuery($query, $boolean, $not);
    }

Usage Example

Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function applyFilterConstraint(QueryBuilder $builder, $data)
 {
     if (empty($data)) {
         return;
     }
     $builder->whereExists(function ($q) use($data) {
         $this->initNestedQuery($q, $this->parseData($data));
     });
 }
All Usage Examples Of Illuminate\Database\Query\Builder::whereExists