Skip to content

Commit

Permalink
Merge pull request #50 from changeweb/master
Browse files Browse the repository at this point in the history
Make search Case Insensetive.
  • Loading branch information
nicolaslopezj committed May 8, 2015
2 parents cd6b430 + 0c11e78 commit d7267eb
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 d7267eb

Please sign in to comment.