1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-06 21:04:06 +00:00

Wrap withoutPending where clauses in a closure

Prevent issues like `Tenant::withoutPending()->where('id', 'nonexistent-id')->first()` returning the first non-pending tenant.
This commit is contained in:
lukinovec 2026-04-22 13:03:00 +02:00
parent f881203af8
commit eed66c93f1

View file

@ -58,8 +58,10 @@ class PendingScope implements Scope
{ {
$builder->macro('withoutPending', function (Builder $builder) { $builder->macro('withoutPending', function (Builder $builder) {
$builder->withoutGlobalScope(static::class) $builder->withoutGlobalScope(static::class)
->whereNull($builder->getModel()->getColumnForQuery('pending_since')) ->where(function (Builder $builder) {
$builder->whereNull($builder->getModel()->getColumnForQuery('pending_since'))
->orWhereNull($builder->getModel()->getDataColumn()); ->orWhereNull($builder->getModel()->getDataColumn());
});
return $builder; return $builder;
}); });