Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
n7olkachev committed Aug 24, 2017
1 parent 5680f9c commit 8b5d222
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Filterable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ public function scopeFilter($query, array $filterData = [])
{
foreach ($filterData as $key => $value) {
if (is_null($value) || $value === '') continue;
if (method_exists($this, 'scope' . ucfirst(camel_case($key)))) {
$query->{ucfirst(camel_case($key))}($value);

$scopeName = ucfirst(camel_case($key));

if (method_exists($this, 'scope' . $scopeName)) {
$query->$scopeName($value);
} else if (is_array($value)) {
$query->whereIn($key, $value);
} else {
Expand Down

0 comments on commit 8b5d222

Please sign in to comment.