Skip to content

Commit d0afb95

Browse files
committed
[Builder] Add method withoutGlobalScope
1 parent 8f131e7 commit d0afb95

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/Builder.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ class Builder
3232
*/
3333
public function getQuery()
3434
{
35-
return $this->query;
35+
return array_merge(
36+
array_merge(...array_values($this->scopes)),
37+
$this->query
38+
);
3639
}
3740

3841
/**
@@ -183,7 +186,20 @@ public function forPage($page, $perPage = 15)
183186
public function withGlobalScope($identifier, array $scope)
184187
{
185188
$this->scopes[$identifier] = $scope;
186-
$this->where($scope);
189+
190+
return $this;
191+
}
192+
193+
/**
194+
* Remove a registered global scope.
195+
*
196+
* @param string $identifier
197+
* @return $this
198+
*/
199+
public function withoutGlobalScope(string $identifier)
200+
{
201+
unset($this->scopes[$identifier]);
202+
$this->removedScopes[] = $identifier;
187203

188204
return $this;
189205
}

0 commit comments

Comments
 (0)