Skip to content

Commit

Permalink
Merge pull request #5 from boz14676/master
Browse files Browse the repository at this point in the history
Change FuzzySearch.
  • Loading branch information
DevDynamo2024 authored Sep 2, 2019
2 parents 3825175 + 9da117f commit 3df522c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Uniqueway/Repositories/Criteria/FuzzySearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,15 @@ public function apply($model, Repository $repository)
return $model;
}

$where = 'where';
foreach ($this->attributes as $attribute) {
if ($attribute == 'id' && preg_match('/^\d+$/', $this->query)) {
$model = $model->$where($attribute, '=', $this->query);
} else {
$pattern = '%' . $this->query . '%';
$model = $model->$where($attribute, 'LIKE', $pattern);
return $model->where(function ($query) {
foreach ($this->attributes as $attribute) {
if ($attribute == 'id' && preg_match('/^\d+$/', $this->query)) {
$query->orWhere($attribute, '=', $this->query);
} else {
$pattern = '%' . $this->query . '%';
$query->orWhere($attribute, 'LIKE', $pattern);
}
}

$where = 'orWhere';
}

return $model;
});
}
}

0 comments on commit 3df522c

Please sign in to comment.