mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 18:04:03 +00:00
Make --with-pending override include_in_queries when passed
Pasing --with-pending, --with-pending=1 or --with-pending=true now makes tenant commands include pending tenants regardless of the include_in_queries config, and passing --with-pending=false, --with-pending=0 or --with-pending=foo makes the commands exclude pending tenants.
This commit is contained in:
parent
984911946a
commit
950ff0fbfd
1 changed files with 6 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ trait HasTenantOptions
|
|||
{
|
||||
return array_merge([
|
||||
new InputOption('tenants', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_OPTIONAL, 'The tenants to run this command for. Leave empty for all tenants', null),
|
||||
new InputOption('with-pending', null, InputOption::VALUE_NONE, 'Include pending tenants in query'), // todo@pending should we also offer without-pending? if we add this, mention in docs
|
||||
new InputOption('with-pending', null, InputOption::VALUE_OPTIONAL, 'Include pending tenants in query if true/1, exclude if false/0. Defaults to the tenancy.pending.include_in_queries config value.'), // todo@pending mention in docs
|
||||
], parent::getOptions());
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,11 @@ trait HasTenantOptions
|
|||
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
|
||||
})
|
||||
->when(tenancy()->model()::hasGlobalScope(PendingScope::class), function ($query) {
|
||||
$query->withPending(config('tenancy.pending.include_in_queries') ?: $this->option('with-pending'));
|
||||
$includePending = $this->input->hasParameterOption('--with-pending')
|
||||
? filter_var($this->option('with-pending') ?? true, FILTER_VALIDATE_BOOLEAN)
|
||||
: config('tenancy.pending.include_in_queries');
|
||||
|
||||
$query->withPending($includePending);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue