Skip to content

Commit

Permalink
Merge pull request #2 from lacodix/feat/github-actions
Browse files Browse the repository at this point in the history
feat(function): added withGlobalOrScope
  • Loading branch information
renky authored Feb 19, 2024
2 parents ec199ed + 602abd1 commit 84751e6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Scopes/OrScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,29 @@ public function apply(Builder $builder, Model $model): Builder
*/
public function extend(Builder $builder): void
{
$this->addWithGlobalOrScope($builder);
$this->addWithGlobalOrScopes($builder);

Check failure on line 48 in src/Scopes/OrScope.php

View workflow job for this annotation

GitHub Actions / 8.1 - prefer-stable

Call to an undefined method Lacodix\LaravelGlobalOrScope\Scopes\OrScope::addWithGlobalOrScopes().
$this->addWithoutGlobalOrScope($builder);
$this->addWithoutGlobalOrScopes($builder);
$this->addRemovedOrScopes($builder);
}

/**
* @param Builder<Model> $builder
*/
protected function addWithGlobalOrScope(Builder $builder): void
{
$builder->macro('withGlobalOrScope', function (Builder $builder, $identifier, $scope) {
$this->scopes[$identifier] = $scope;

if (method_exists($scope, 'extend')) {
$scope->extend($builder);
}

return $builder;
});
}

/**
* @param Builder<Model> $builder
*/
Expand Down

0 comments on commit 84751e6

Please sign in to comment.