From 85ff8054118976a791b8ff989c290f88717e373c Mon Sep 17 00:00:00 2001 From: mphaedok <40614383+mphaedok@users.noreply.github.com> Date: Sat, 23 Nov 2024 16:01:38 -0500 Subject: [PATCH] Allow json in relationship --- src/Filterable.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Filterable.php b/src/Filterable.php index 28ec8f1..1d19c17 100644 --- a/src/Filterable.php +++ b/src/Filterable.php @@ -170,14 +170,16 @@ public function applyFilterToQuery($filterType, $filterName, $filterValue, $oper if (!empty($relationship)) { return $query->whereHas( Str::camel($relationship), - function($query) use($method, $filterName, $operator, $filterValue, $filterRelationshipQuery, $filterType) { + function($query) use($method, $filterName, $operator, $filterValue, $filterRelationshipQuery, $filterType, $jsonPath) { if (! empty($filterRelationshipQuery)) { $query->where($filterRelationshipQuery); } if ($filterType == 'array') { return $query->$method($filterName, $filterValue); } - + if (! empty($jsonPath)) { + return $query->$method("$filterName->$jsonPath", $operator, $filterValue); + } return $query->$method($filterName, $operator, $filterValue); } );