mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 07:34:02 +00:00
Dynamically get columns for pending queries
This commit is contained in:
parent
a13384dede
commit
789a05b125
1 changed files with 4 additions and 4 deletions
|
|
@ -25,7 +25,7 @@ class PendingScope implements Scope
|
||||||
public function apply(Builder $builder, Model $model)
|
public function apply(Builder $builder, Model $model)
|
||||||
{
|
{
|
||||||
$builder->when(! config('tenancy.pending.include_in_queries'), function (Builder $builder) {
|
$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->macro('withoutPending', function (Builder $builder) {
|
||||||
$builder->withoutGlobalScope($this)
|
$builder->withoutGlobalScope($this)
|
||||||
->whereNull('data->pending_since')
|
->whereNull($builder->getModel()->getColumnForQuery('pending_since'))
|
||||||
->orWhereNull('data');
|
->orWhereNull($builder->getModel()->getDataColumn());
|
||||||
|
|
||||||
return $builder;
|
return $builder;
|
||||||
});
|
});
|
||||||
|
|
@ -80,7 +80,7 @@ class PendingScope implements Scope
|
||||||
protected function addOnlyPending(Builder $builder)
|
protected function addOnlyPending(Builder $builder)
|
||||||
{
|
{
|
||||||
$builder->macro('onlyPending', function (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;
|
return $builder;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue