From 0c11e78340e0f7a6b07e09c1e87a7e2484f1a16c Mon Sep 17 00:00:00 2001 From: Hasib Mahmud Date: Fri, 8 May 2015 23:25:43 +0600 Subject: [PATCH] Make search Case Insensetive. --- src/SearchableTrait.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SearchableTrait.php b/src/SearchableTrait.php index 9b17734..472eb82 100644 --- a/src/SearchableTrait.php +++ b/src/SearchableTrait.php @@ -35,7 +35,8 @@ public function scopeSearch(Builder $q, $search, $threshold = null) { return $q; } - + + $search = strtolower($search); $words = explode(' ', $search); $selects = []; $this->search_bindings = []; @@ -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)'; }