Skip to content

Commit

Permalink
chore: Do not apply condition from scopes when outside multitenanted …
Browse files Browse the repository at this point in the history
…context
  • Loading branch information
ollieread committed Nov 18, 2024
1 parent 11834a8 commit 4329fa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Database/Eloquent/Scopes/BelongsToManyTenantsScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Sprout\Exceptions\TenantMissing;
use function Sprout\sprout;

/**
* Belongs to many Tenants Scope
Expand Down Expand Up @@ -38,6 +39,10 @@ final class BelongsToManyTenantsScope extends TenantChildScope
*/
public function apply(Builder $builder, Model $model): void
{
if (! sprout()->withinContext()) {
return;
}

/** @phpstan-ignore-next-line */
$tenancy = $model->getTenancy();

Expand Down
5 changes: 5 additions & 0 deletions src/Database/Eloquent/Scopes/BelongsToTenantScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Sprout\Exceptions\TenantMissing;
use function Sprout\sprout;

/**
* Belongs to Tenant Scope
Expand Down Expand Up @@ -38,6 +39,10 @@ final class BelongsToTenantScope extends TenantChildScope
*/
public function apply(Builder $builder, Model $model): void
{
if (! sprout()->withinContext()) {
return;
}

/** @phpstan-ignore-next-line */
$tenancy = $model->getTenancy();

Expand Down

0 comments on commit 4329fa8

Please sign in to comment.