src/Database/Builder.php
protected function searchInternal($term, $columns = [], $mode, $boolean)
    {
        if (!is_array($columns))
            $columns = [$columns];

        if (!$mode)
            $mode = 'all';

        if ($mode === 'exact') {
            $this->where(function ($query) use ($columns, $term) {
                foreach ($columns as $field) {
                    if (!strlen($term)) continue;
                    $query->orLike($field, $term, 'both');
                }
            }, null, null, $boolean);
        }
        else {
            $words = explode(' ', $term);
            $wordBoolean = $mode === 'any' ? 'or' : 'and';

            $this->where(function ($query) use ($columns, $words, $wordBoolean) {
                foreach ($columns as $field) {
                    $query->orWhere(function ($query) use ($field, $words, $wordBoolean) {
                        foreach ($words as $word) {
                            if (!strlen($word)) continue;
                            $query->like($field, $word, 'both', $wordBoolean);
                        }
                    });
                }
            }, null, null, $boolean);
        }

        return $this;
    }
protected function searchInternal($term, $columns = [], $mode, $boolean)
    {
        if (!is_array($columns))
            $columns = [$columns];

        if (!$mode)
            $mode = 'all';

        if ($mode === 'exact') {
            $this->where(function ($query) use ($columns, $term) {
                foreach ($columns as $field) {
                    if (!strlen($term)) continue;
                    $query->orLike($field, $term, 'both');
                }
            }, null, null, $boolean);
        }
        else {
            $words = explode(' ', $term);
            $wordBoolean = $mode === 'any' ? 'or' : 'and';

            $this->where(function ($query) use ($columns, $words, $wordBoolean) {
                foreach ($columns as $field) {
                    $query->orWhere(function ($query) use ($field, $words, $wordBoolean) {
                        foreach ($words as $word) {
                            if (!strlen($word)) continue;
                            $query->like($field, $word, 'both', $wordBoolean);
                        }
                    });
                }
            }, null, null, $boolean);
        }

        return $this;
    }
Internal method to apply a search constraint to the query.
Mode can be any of these options:
- all: result must contain all words
- any: result can contain any word
- exact: result must contain the exact phrase

@param $term
@param array $columns
@param $mode
@param $boolean

@return $this