Skip to content

Commit

Permalink
add excluded parameters feature
Browse files Browse the repository at this point in the history
  • Loading branch information
selahattinunlu committed Dec 3, 2015
1 parent 5f8733d commit 3e141c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class QueryBuilder

protected $groupBy = [];

protected $excludedParameters = [];

protected $query;

protected $result;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
'column' => 'id',
'direction' => 'desc'
]
]
],

'excludedParameters' => [],

];

0 comments on commit 3e141c7

Please sign in to comment.