mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:54:03 +00:00
Update tenants option trait
This commit is contained in:
parent
fd809bc81a
commit
f92b682eb3
1 changed files with 7 additions and 6 deletions
|
|
@ -7,7 +7,10 @@ namespace Stancl\Tenancy\Concerns;
|
||||||
use Illuminate\Support\LazyCollection;
|
use Illuminate\Support\LazyCollection;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
trait HasATenantsOption
|
/**
|
||||||
|
* Adds 'tenants' and 'with-pending' options.
|
||||||
|
*/
|
||||||
|
trait HasTenantOptions
|
||||||
{
|
{
|
||||||
protected function getOptions()
|
protected function getOptions()
|
||||||
{
|
{
|
||||||
|
|
@ -24,14 +27,12 @@ trait HasATenantsOption
|
||||||
->when($this->option('tenants'), function ($query) {
|
->when($this->option('tenants'), function ($query) {
|
||||||
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
|
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
|
||||||
})
|
})
|
||||||
|
->when(tenancy()->model()::hasGlobalScope(PendingScope::class), function($query) {
|
||||||
|
$query->withPending($this->option('with-pending'));
|
||||||
|
})
|
||||||
->cursor();
|
->cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function withPending(): ?bool
|
|
||||||
{
|
|
||||||
return $this->option('with-pending') ? true : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue