diff --git a/src/Expression.php b/src/Expression.php index 18ccbec..d4c479f 100644 --- a/src/Expression.php +++ b/src/Expression.php @@ -64,7 +64,7 @@ function ($expression) { /** * Returns the filters generated by the expression - * + * * @return array */ public function getExpressionFilters(): array @@ -74,7 +74,7 @@ public function getExpressionFilters(): array /** * Adds or filter - * + * * @param array|Expression $expression * * @return $this|Expression @@ -125,6 +125,78 @@ public function notEqual(string $field, $value): Expression return $this; } + /** + * Adds gt filter + * + * @param string $field + * @param string $value + * + * @return $this|Expression + */ + + public function greaterThan(string $field, $value): Expression + { + $this->prepareFilterIndex($field); + + $this->filters[$field] = $this->operationExpression('$gt', $value); + + return $this; + } + + /** + * Adds gte filter + * + * @param string $field + * @param string $value + * + * @return $this|Expression + */ + + public function greaterEqualThan(string $field, $value): Expression + { + $this->prepareFilterIndex($field); + + $this->filters[$field] = $this->operationExpression('$gte', $value); + + return $this; + } + + /** + * Adds lt filter + * + * @param string $field + * @param string $value + * + * @return $this|Expression + */ + + public function lowerThan(string $field, $value): Expression + { + $this->prepareFilterIndex($field); + + $this->filters[$field] = $this->operationExpression('$lt', $value); + + return $this; + } + + /** + * Adds lte filter + * + * @param string $field + * @param string $value + * + * @return $this|Expression + */ + + public function lowerEqualThan(string $field, $value): Expression + { + $this->prepareFilterIndex($field); + + $this->filters[$field] = $this->operationExpression('$lte', $value); + + return $this; + } + /** * Adds in filter * diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index b6ed130..3540b8d 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -121,6 +121,70 @@ public function notEqual(string $field, $value) return $this; } + /** + * Adds gt filter + * + * @param string $field + * @param mixed $value + * + * @return $this + */ + + public function greaterThan(string $field, $value) + { + $this->expression->greaterThan($field,$value); + + return $this; + } + + /** + * Adds gte filter + * + * @param string $field + * @param mixed $value + * + * @return $this + */ + + public function greaterEqualThan(string $field, $value) + { + $this->expression->greaterEqualThan($field,$value); + + return $this; + } + + /** + * Adds lt filter + * + * @param string $field + * @param mixed $value + * + * @return $this + */ + + public function lowerThan(string $field, $value) + { + $this->expression->lowerThan($field,$value); + + return $this; + } + + /** + * Adds lte filter + * + * @param string $field + * @param mixed $value + * + * @return $this + */ + + public function lowerEqualThan(string $field, $value) + { + $this->expression->lowerEqualThan($field,$value); + + return $this; + } + /** * Adds in filter *