Skip to content

Commit

Permalink
Use accessor for search queries (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvansteen authored Feb 4, 2020
1 parent 0f4cc92 commit dd59476
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Traits/SearchesQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ protected function applySearch(Builder $query, Arguments $args)
$qualifiedNeedle = preg_quote($needle);

foreach ($fields as $key => $value) {
$field = $this->modelSchema->getFieldByKey($key);
$accessor = $field->getAccessor();
if ($relations->keys()->contains($key)) {
$this->applyRelationalSearch($query, $this->model, $key, $needle, $value->toArray());
$this->applyRelationalSearch($query, $this->model, $accessor, $needle, $value->toArray());
} else {
$this->tsFields[] = $this->model->getTable().'.'.$key;
$this->tsFields[] = $this->model->getTable().'.'.$accessor;
}
}

Expand Down

0 comments on commit dd59476

Please sign in to comment.