src/Jedrzej/Searchable/Constraint.php
public function apply(Builder $builder, $field, $mode = Constraint::MODE_AND)
    {
        if ($this->isRelation($field)) {
            list($relation, $field) = $this->splitRelationField($field);
            if (static::parseIsNegation($relation)) {
                $builder->whereDoesntHave($relation, function (Builder $builder) use ($field, $mode) {
                    $this->doApply($builder, $field, $mode);
                });
            } else {
                $builder->whereHas($relation, function (Builder $builder) use ($field, $mode) {
                    $this->doApply($builder, $field, $mode);
                });
            }
        } else {
            $this->doApply($builder, $field, $mode);
        }
    }
public function apply(Builder $builder, $field, $mode = Constraint::MODE_AND)
    {
        if ($this->isRelation($field)) {
            list($relation, $field) = $this->splitRelationField($field);
            if (static::parseIsNegation($relation)) {
                $builder->whereDoesntHave($relation, function (Builder $builder) use ($field, $mode) {
                    $this->doApply($builder, $field, $mode);
                });
            } else {
                $builder->whereHas($relation, function (Builder $builder) use ($field, $mode) {
                    $this->doApply($builder, $field, $mode);
                });
            }
        } else {
            $this->doApply($builder, $field, $mode);
        }
    }
public function apply ( Builder $ builder , $ field , $ mode = Constraint :: MODE_AND ) { if ( $ this -> isRelation ( $ field ) ) { list ( $ relation , $ field ) = $ this -> splitRelationField ( $ field ) ; if ( static :: parseIsNegation ( $ relation ) ) { $ builder -> whereDoesntHave ( $ relation , function ( Builder $ builder ) use ( $ field , $ mode ) { $ this -> doApply ( $ builder , $ field , $ mode ) ; } ) ; } else { $ builder -> whereHas ( $ relation , function ( Builder $ builder ) use ( $ field , $ mode ) { $ this -> doApply ( $ builder , $ field , $ mode ) ; } ) ; } } else { $ this -> doApply ( $ builder , $ field , $ mode ) ; } }
Applies constraint to query.

@param Builder $builder query builder
@param string $field field name
@param string $mode determines how constraint is added to existing query ("or" or "and")
Applies constraint to query .