Skip to content

Commit

Permalink
Make search Case Insensetive.
Browse files Browse the repository at this point in the history
  • Loading branch information
changeweb committed May 8, 2015
1 parent cd6b430 commit 0c11e78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/SearchableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public function scopeSearch(Builder $q, $search, $threshold = null)
{
return $q;
}


$search = strtolower($search);
$words = explode(' ', $search);
$selects = [];
$this->search_bindings = [];
Expand Down Expand Up @@ -234,7 +235,7 @@ protected function getSearchQuery(Builder $query, $column, $relevance, array $wo
* @return string
*/
protected function getCaseCompare($column, $compare, $relevance) {
$field = $column . " " . $compare . " ?";
$field = "LOWER(" . $column . ") " . $compare . " ?";
return '(case when ' . $field . ' then ' . $relevance . ' else 0 end)';
}

Expand Down

0 comments on commit 0c11e78

Please sign in to comment.