Skip to content

Commit

Permalink
[Builder] Add method withoutGlobalScope
Browse files Browse the repository at this point in the history
  • Loading branch information
ffouchier committed Oct 29, 2020
1 parent 8f131e7 commit d0afb95
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class Builder
*/
public function getQuery()
{
return $this->query;
return array_merge(
array_merge(...array_values($this->scopes)),
$this->query
);
}

/**
Expand Down Expand Up @@ -183,7 +186,20 @@ public function forPage($page, $perPage = 15)
public function withGlobalScope($identifier, array $scope)
{
$this->scopes[$identifier] = $scope;
$this->where($scope);

return $this;
}

/**
* Remove a registered global scope.
*
* @param string $identifier
* @return $this
*/
public function withoutGlobalScope(string $identifier)
{
unset($this->scopes[$identifier]);
$this->removedScopes[] = $identifier;

return $this;
}
Expand Down

1 comment on commit d0afb95

@MiloDBD
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could $scopes be null at any point?

Please sign in to comment.