From 4d7d1a09a4ef8ee9cc9b016ec4bf69e4daa24b73 Mon Sep 17 00:00:00 2001 From: Mark Beech Date: Tue, 26 Sep 2023 14:49:46 +0100 Subject: [PATCH] Allow `not` expressions --- src/Traits/FilterByDimensionTrait.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Traits/FilterByDimensionTrait.php b/src/Traits/FilterByDimensionTrait.php index 8304918..493b574 100644 --- a/src/Traits/FilterByDimensionTrait.php +++ b/src/Traits/FilterByDimensionTrait.php @@ -94,6 +94,27 @@ public function whereOrGroupDimensions($dimensions): self return $this; } + /** + * Apply whereNot dimension filter. + * + * @return $this + */ + public function whereNotDimension(string $name, int $matchType, $value, bool $caseSensitive = false): self + { + $stringFilter = (new StringFilter())->setCaseSensitive($caseSensitive) + ->setMatchType($matchType) + ->setValue($value); + + $filter = (new Filter())->setStringFilter($stringFilter) + ->setFieldName($name); + + $this->dimensionFilter = (new FilterExpression())->setNotExpression( + (new FilterExpression())->setFilter($filter) + ); + + return $this; + } + /** * Create an array of dimension filters. *