From eed66c93f1d96621c14c09810adc4175f0588788 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 22 Apr 2026 13:03:00 +0200 Subject: [PATCH] Wrap withoutPending where clauses in a closure Prevent issues like `Tenant::withoutPending()->where('id', 'nonexistent-id')->first()` returning the first non-pending tenant. --- src/Database/Concerns/PendingScope.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Database/Concerns/PendingScope.php b/src/Database/Concerns/PendingScope.php index 52b8eb19..402cd2db 100644 --- a/src/Database/Concerns/PendingScope.php +++ b/src/Database/Concerns/PendingScope.php @@ -58,8 +58,10 @@ class PendingScope implements Scope { $builder->macro('withoutPending', function (Builder $builder) { $builder->withoutGlobalScope(static::class) - ->whereNull($builder->getModel()->getColumnForQuery('pending_since')) - ->orWhereNull($builder->getModel()->getDataColumn()); + ->where(function (Builder $builder) { + $builder->whereNull($builder->getModel()->getColumnForQuery('pending_since')) + ->orWhereNull($builder->getModel()->getDataColumn()); + }); return $builder; });