From 789a05b125765c979f0667b03a0683fc0ec4457e Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 21 Oct 2022 14:59:43 +0200 Subject: [PATCH] Dynamically get columns for pending queries --- src/Database/Concerns/PendingScope.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Database/Concerns/PendingScope.php b/src/Database/Concerns/PendingScope.php index f28988d4..8a6ad913 100644 --- a/src/Database/Concerns/PendingScope.php +++ b/src/Database/Concerns/PendingScope.php @@ -25,7 +25,7 @@ class PendingScope implements Scope public function apply(Builder $builder, Model $model) { $builder->when(! config('tenancy.pending.include_in_queries'), function (Builder $builder) { - $builder->whereNull('data->pending_since'); + $builder->whereNull($builder->getModel()->getColumnForQuery('pending_since')); }); } @@ -65,8 +65,8 @@ class PendingScope implements Scope { $builder->macro('withoutPending', function (Builder $builder) { $builder->withoutGlobalScope($this) - ->whereNull('data->pending_since') - ->orWhereNull('data'); + ->whereNull($builder->getModel()->getColumnForQuery('pending_since')) + ->orWhereNull($builder->getModel()->getDataColumn()); return $builder; }); @@ -80,7 +80,7 @@ class PendingScope implements Scope protected function addOnlyPending(Builder $builder) { $builder->macro('onlyPending', function (Builder $builder) { - $builder->withoutGlobalScope($this)->whereNotNull('data->pending_since'); + $builder->withoutGlobalScope($this)->whereNotNull($builder->getModel()->getColumnForQuery('pending_since')); return $builder; });