diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index b0df753..16da431 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -216,8 +216,10 @@ protected function prepareQuery($model) } // Add a "scope" to the query - foreach ($this->scopes as $scope => $parameters) { - $model = $model->{$scope}(...$parameters); + foreach ($this->scopes as $name => $scopes) { + foreach ($scopes as $parameters) { + $model = $model->{$name}(...$parameters); + } } // Set the "offset" value of the query @@ -396,7 +398,7 @@ public function whereHas($relation, Closure $callback = null, $operator = '>=', */ public function scope($name, array $parameters = []) { - $this->scopes[$name] = $parameters; + $this->scopes[$name][] = $parameters; return $this; }