Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Fix scope #189

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Repositories/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down