diff --git a/src/Traits/SearchesQueries.php b/src/Traits/SearchesQueries.php index 6f59987e..887e1453 100644 --- a/src/Traits/SearchesQueries.php +++ b/src/Traits/SearchesQueries.php @@ -37,7 +37,7 @@ protected function applySearch(Builder $query, array $args) $fields = $args['fields']; $relations = $this->modelSchema->getRelationFields(); - $qualifiedNeedle = preg_replace('/[*&|:\']+/', ' ', $needle); + $qualifiedNeedle = preg_quote($needle); foreach ($fields as $key => $value) { if ($relations->keys()->contains($key)) { @@ -56,7 +56,7 @@ protected function applySearch(Builder $query, array $args) if ($grammar instanceof Grammars\PostgresGrammar) { $dictionary = config('bakery.postgresDictionary'); $fields = implode(', ', $this->tsFields); - $query->whereRaw("to_tsvector('${dictionary}', concat_ws(' ', ".$fields.")) @@ to_tsquery('${dictionary}', ?)", ["'$qualifiedNeedle':*"]); + $query->whereRaw("to_tsvector('${dictionary}', concat_ws(' ', ".$fields.")) @@ to_tsquery('${dictionary}', ?)", ["'{$qualifiedNeedle}':*"]); } return $query;