Skip to content

Commit

Permalink
Fixed display scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed May 11, 2016
1 parent cd50433 commit d1fa13d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Display/Extension/Scopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SleepingOwl\Admin\Display\Extension;

use Illuminate\Database\Eloquent\Builder;

class Scopes extends Extension
{
/**
Expand All @@ -24,13 +26,9 @@ public function all()
*/
public function set(array $scopes)
{
if (! is_array($scopes)) {
$scopes = func_get_args();
}
$this->scopes = func_get_args();

$this->scopes = $scopes;

return $this;
return $this->getDisplay();
}

/**
Expand Down Expand Up @@ -62,18 +60,24 @@ public function toArray()
}

/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param Builder $query
*/
public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query)
public function modifyQuery(Builder $query)
{
foreach ($this->scopes as $scope) {
if (! is_null($scope)) {
$method = array_shift($scope);
if (is_array($scope)) {
$method = array_shift($scope);
$params = $scope;
} else {
$method = $scope;
$params = [];
}

call_user_func_array([
$query,
$method,
], $scope);
], $params);
}
}
}
Expand Down

0 comments on commit d1fa13d

Please sign in to comment.