Skip to content

Commit

Permalink
Remove where clause requirement for full text search
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhuisinga committed Dec 2, 2022
1 parent c8977a2 commit ec69768
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/Searchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public function scopeSearch(Builder $query, $search, $restriction = null)

$this->addSelectsToQuery($cloned_query, $selects);
$this->filterQueryWithRelevance($cloned_query, $relevance_count);
$this->makeWhere($cloned_query);
$this->makeGroupBy($cloned_query);

if ($restriction instanceof Closure) {
Expand Down Expand Up @@ -437,24 +436,6 @@ protected function filterQueryWithRelevance(Builder $query, $relevance_count)
$query->orderBy('relevance', 'desc');
}

/**
* Adds where clause to query to deal with fulltext columns.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*/
protected function makeWhere(Builder $query)
{
if ($this->getDatabaseDriver() === 'sqlite') {
return;
}

foreach ($this->getFullTextColumns() as $column => $relevance) {
$column = str_replace('.', '`.`', $column);

$query->whereRaw("MATCH (`$column`) AGAINST (?)", [implode(' ', $this->orderedWords)]);
}
}

/**
* Makes the query not repeat the results.
*
Expand Down

0 comments on commit ec69768

Please sign in to comment.