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

Dynamically get columns for pending queries

This commit is contained in:
lukinovec 2022-10-21 14:59:43 +02:00
parent a13384dede
commit 789a05b125

View file

@ -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;
});