From b8251a85ea25785c9c4c3b61f2cc15c87622c6b8 Mon Sep 17 00:00:00 2001 From: inmula Date: Tue, 21 May 2024 12:06:09 +0200 Subject: [PATCH] Fix ability to filter models by an array as filter value --- src/Filters/FiltersPartial.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Filters/FiltersPartial.php b/src/Filters/FiltersPartial.php index cb86d6cd..f5c38385 100644 --- a/src/Filters/FiltersPartial.php +++ b/src/Filters/FiltersPartial.php @@ -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); }