Skip to content

Commit

Permalink
Fix ability to filter models by an array as filter value
Browse files Browse the repository at this point in the history
  • Loading branch information
inmula authored May 21, 2024
1 parent 41278ce commit b8251a8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Filters/FiltersPartial.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public function __invoke(Builder $query, $value, string $property)
$databaseDriver = $this->getDatabaseDriver($query);

if (is_array($value)) {
if (count(array_filter($value, fn ($item) => empty($item))) === 0) {
if (count(array_filter($value, fn ($item) => strlen($item) > 0)) === 0) {
return $query;
}

$query->where(function (Builder $query) use ($databaseDriver, $value, $wrappedProperty) {
foreach (array_filter($value, fn ($item) => empty($item)) as $partialValue) {
foreach (array_filter($value, fn ($item) => strlen($item) > 0) as $partialValue) {
[$sql, $bindings] = $this->getWhereRawParameters($partialValue, $wrappedProperty, $databaseDriver);
$query->orWhereRaw($sql, $bindings);
}
Expand Down

0 comments on commit b8251a8

Please sign in to comment.