diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 2720957..b629a34 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -34,6 +34,8 @@ class QueryBuilder protected $groupBy = []; + protected $excludedParameters = []; + protected $query; protected $result; @@ -43,7 +45,9 @@ public function __construct(Model $model, Request $request) $this->orderBy = config('api-query-builder.orderBy'); $this->limit = config('api-query-builder.limit'); - + + $this->excludedParameters = array_merge($this->excludedParameters, config('api-query-builder.excludedParameters')); + $this->model = $model; $this->uriParser = new UriParser($request); @@ -232,6 +236,10 @@ private function addWhereToQuery($where) { extract($where); + if ($this->isExcludedParameter($key)) { + return; + } + if ($this->hasCustomFilter($key)) { return $this->applyCustomFilter($key, $operator, $value); } @@ -266,6 +274,11 @@ private function isRelationColumn($column) return (count(explode('.', $column)) > 1); } + private function isExcludedParameter($key) + { + return in_array($key, $this->excludedParameters); + } + private function hasWheres() { return (count($this->wheres) > 0); diff --git a/src/config.php b/src/config.php index 998226a..52a2881 100644 --- a/src/config.php +++ b/src/config.php @@ -9,6 +9,8 @@ 'column' => 'id', 'direction' => 'desc' ] - ] + ], + + 'excludedParameters' => [], ]; \ No newline at end of file