Skip to content

Commit

Permalink
Merge pull request #139 from kordero/master
Browse files Browse the repository at this point in the history
search query: content in quotes is treated as a single word
  • Loading branch information
nicolaslopezj authored Aug 9, 2017
2 parents 0f018ce + 262057a commit c067f11
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/SearchableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public function scopeSearchRestricted(Builder $q, $search, $restriction, $thresh
}

$search = mb_strtolower(trim($search));
$words = explode(' ', $search);
preg_match_all('/(?:")((?:\\\\.|[^\\\\"])*)(?:")|(\S+)/', $search, $matches);
$words = $matches[1];
for ($i = 2; $i < count($matches); $i++) {
$words = array_filter($words) + $matches[$i];
}

$selects = [];
$this->search_bindings = [];
Expand Down

0 comments on commit c067f11

Please sign in to comment.