Skip to content

Commit

Permalink
Merge pull request #943 from inmula/main
Browse files Browse the repository at this point in the history
Fix ability to filter models by an array as filter value
  • Loading branch information
freekmurze authored May 21, 2024
2 parents 41278ce + b8251a8 commit 69a6fd3
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 69a6fd3

Please sign in to comment.