Skip to content

Commit 3e141c7

Browse files
add excluded parameters feature
1 parent 5f8733d commit 3e141c7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/QueryBuilder.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class QueryBuilder
3434

3535
protected $groupBy = [];
3636

37+
protected $excludedParameters = [];
38+
3739
protected $query;
3840

3941
protected $result;
@@ -43,7 +45,9 @@ public function __construct(Model $model, Request $request)
4345
$this->orderBy = config('api-query-builder.orderBy');
4446

4547
$this->limit = config('api-query-builder.limit');
46-
48+
49+
$this->excludedParameters = array_merge($this->excludedParameters, config('api-query-builder.excludedParameters'));
50+
4751
$this->model = $model;
4852

4953
$this->uriParser = new UriParser($request);
@@ -232,6 +236,10 @@ private function addWhereToQuery($where)
232236
{
233237
extract($where);
234238

239+
if ($this->isExcludedParameter($key)) {
240+
return;
241+
}
242+
235243
if ($this->hasCustomFilter($key)) {
236244
return $this->applyCustomFilter($key, $operator, $value);
237245
}
@@ -266,6 +274,11 @@ private function isRelationColumn($column)
266274
return (count(explode('.', $column)) > 1);
267275
}
268276

277+
private function isExcludedParameter($key)
278+
{
279+
return in_array($key, $this->excludedParameters);
280+
}
281+
269282
private function hasWheres()
270283
{
271284
return (count($this->wheres) > 0);

src/config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
'column' => 'id',
1010
'direction' => 'desc'
1111
]
12-
]
12+
],
13+
14+
'excludedParameters' => [],
1315

1416
];

0 commit comments

Comments
 (0)