Skip to content

Commit

Permalink
Adds withSyncSites to query
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed May 10, 2024
1 parent 0ade9dc commit 8ec3f78
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Database/Scopes/MultisiteScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MultisiteScope implements ScopeInterface
/**
* @var array extensions to be added to the builder.
*/
protected $extensions = ['WithSite', 'WithSites'];
protected $extensions = ['WithSite', 'WithSites', 'WithSyncSites'];

/**
* apply the scope to a given Eloquent query builder.
Expand All @@ -29,7 +29,7 @@ public function apply(BuilderBase $builder, ModelBase $model)
}

/**
* addWithSite
* addWithSite removes this scope and includes the specified site
*/
protected function addWithSite(BuilderBase $builder)
{
Expand Down Expand Up @@ -58,6 +58,16 @@ protected function addWithSites(BuilderBase $builder)
});
}

/**
* addWithSyncSites removes this scope and includes sites that should be synced with this model
*/
protected function addWithSyncSites(BuilderBase $builder)
{
$builder->macro('withSyncSites', function (BuilderBase $builder) {
return $builder->withSites($builder->getModel()->getMultisiteSyncSites());
});
}

/**
* extend the Eloquent query builder.
*/
Expand Down

0 comments on commit 8ec3f78

Please sign in to comment.