This commit is contained in:
Oliver Davies 2019-04-23 18:31:15 +01:00
parent caa3767246
commit ba5a972715
3 changed files with 43 additions and 7 deletions

View file

@ -275,4 +275,22 @@ class Filter
{
return $this->properties;
}
public function negate(Filter $filter): self
{
$filter->properties = collect($filter->toArray())
->mapWithKeys(function ($conditions, $key) {
return [$key => collect($conditions)->map(function ($condition) {
return $this->negateCondition($condition);
})];
})
->toArray();
return $this;
}
private function negateCondition(string $condition): string
{
return "-($condition)";
}
}