diff --git a/src/Database/Scopes/MultisiteScope.php b/src/Database/Scopes/MultisiteScope.php index b014dec71..97dc394fe 100644 --- a/src/Database/Scopes/MultisiteScope.php +++ b/src/Database/Scopes/MultisiteScope.php @@ -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. @@ -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) { @@ -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. */