mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #382 from sebapastore/fix381
Fix bug when applying multiple column search and filter
This commit is contained in:
@@ -56,21 +56,23 @@ trait CanSearchRecords
|
||||
return $query;
|
||||
}
|
||||
|
||||
collect($this->getTable()->getColumns())
|
||||
->filter(fn ($column) => $column->isSearchable())
|
||||
->each(function ($column) use (&$query) {
|
||||
foreach ($column->getSearchColumns() as $searchColumn) {
|
||||
if ($this->isRelationshipSearch($searchColumn)) {
|
||||
$query = $this->applyRelationshipSearch($query, $searchColumn);
|
||||
} else {
|
||||
$query = $query->{$this->hasNoSearchQueriesApplied() ? 'where' : 'orWhere'}(
|
||||
fn ($query) => $query->where($searchColumn, $this->getSearchOperator(), "%{$this->getSearch()}%"),
|
||||
);
|
||||
}
|
||||
$query->where(function ($query) {
|
||||
collect($this->getTable()->getColumns())
|
||||
->filter(fn ($column) => $column->isSearchable())
|
||||
->each(function ($column) use (&$query) {
|
||||
foreach ($column->getSearchColumns() as $searchColumn) {
|
||||
if ($this->isRelationshipSearch($searchColumn)) {
|
||||
$query = $this->applyRelationshipSearch($query, $searchColumn);
|
||||
} else {
|
||||
$query->{$this->hasNoSearchQueriesApplied() ? 'where' : 'orWhere'}(
|
||||
$searchColumn, $this->getSearchOperator(), "%{$this->getSearch()}%"
|
||||
);
|
||||
}
|
||||
|
||||
$this->hasSearchQueriesApplied = true;
|
||||
}
|
||||
});
|
||||
$this->hasSearchQueriesApplied = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user