<commit_before><?php namespace Nicolaslopezj\Searchable;

use Illuminate\Database\Query\Expression;

/**
 * Trait SearchableTrait
 * @package Nicolaslopezj\Searchable
 */
trait SearchableTrait
{
    /**
     * Makes the search process
     *
     * @param $query
     * @param $search
     * @return mixed
     */
    public function scopeSearch($query, $search)
    {
        $query->select($this->getTable() . '.*');
        $this->makeJoins($query);

        if ( ! $search)
        {
            return $query;
        }

        $words = explode(' ', $search);
        $selects = [];
        $relevance_count = 0;

        foreach ($this->getColumns() as $column => $relevance)
        {
            $relevance_count += $relevance;

            $queries = $this->getSearchQueriesForColumn($column, $relevance, $words);
            $selects = array_merge($queries);
        }

        $this->addSelectsToQuery($query, $selects);
        $this->filterQueryWithRelevace($query, ($relevance_count / 4));

        $this->makeGroupBy($query);

        return $query;
    }
<commit_msg>Fixed error founded by marsd<commit_after><?php namespace Nicolaslopezj\Searchable;

use Illuminate\Database\Query\Expression;

/**
 * Trait SearchableTrait
 * @package Nicolaslopezj\Searchable
 */
trait SearchableTrait
{
    /**
     * Makes the search process
     *
     * @param $query
     * @param $search
     * @return mixed
     */
    public function scopeSearch($query, $search)
    {
        $query->select($this->getTable() . '.*');
        $this->makeJoins($query);

        if ( ! $search)
        {
            return $query;
        }

        $words = explode(' ', $search);
        $selects = [];
        $relevance_count = 0;

        foreach ($this->getColumns() as $column => $relevance)
        {
            $relevance_count += $relevance;

            $queries = $this->getSearchQueriesForColumn($column, $relevance, $words);

            foreach ($queries as $select)
            {
                $selects[] = $select;
            }
        }

        $this->addSelectsToQuery($query, $selects);
        $this->filterQueryWithRelevace($query, ($relevance_count / 4));

        $this->makeGroupBy($query);

        return $query;
    }

{'fraction_non_alphanumeric': 0.1433659839715049, 'fraction_numerical': 0.0017809439002671415, 'mean_word_length': 2.1035911602209945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5621717', 'n_tokens_mistral': 697, 'n_tokens_neox': 666, 'n_words': 124}