From e20347aa06135b59026fe7901d80a231950eaacd Mon Sep 17 00:00:00 2001 From: Lenos Date: Mon, 22 Nov 2021 12:09:48 +0200 Subject: [PATCH] Added functionality to support also filterDisplay=menu --- src/PrimevueDatatables.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/PrimevueDatatables.php b/src/PrimevueDatatables.php index 20259cb..561a64a 100644 --- a/src/PrimevueDatatables.php +++ b/src/PrimevueDatatables.php @@ -81,9 +81,18 @@ public function make(): \Illuminate\Contracts\Pagination\LengthAwarePaginator })->where(function (Builder $q) use ($localFilters) { // Local filters foreach ($localFilters as $field => $filter) { - if (collect($filter)->get("value")) { - $instance = new Filter($field, collect($filter)->get("value"), collect($filter)->get("matchMode")); - $this->applyFilter($instance, $q); + if(isset($filter['constraints'])){ + foreach($filter['constraints'] as $const){ + if ($const["value"]) { + $instance = new Filter($field, $const["value"], $const["matchMode"]); + $this->applyFilter($instance, $q, $filter['operator'] == 'or' ? true : false); + } + } + } else { + if (collect($filter)->get("value")) { + $instance = new Filter($field, collect($filter)->get("value"), collect($filter)->get("matchMode")); + $this->applyFilter($instance, $q); + } } } });