1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 19:14:03 +00:00

Update tenants option trait

This commit is contained in:
lukinovec 2022-07-22 15:10:00 +02:00
parent fd809bc81a
commit f92b682eb3

View file

@ -7,7 +7,10 @@ namespace Stancl\Tenancy\Concerns;
use Illuminate\Support\LazyCollection;
use Symfony\Component\Console\Input\InputOption;
trait HasATenantsOption
/**
* Adds 'tenants' and 'with-pending' options.
*/
trait HasTenantOptions
{
protected function getOptions()
{
@ -24,14 +27,12 @@ trait HasATenantsOption
->when($this->option('tenants'), function ($query) {
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
})
->when(tenancy()->model()::hasGlobalScope(PendingScope::class), function($query) {
$query->withPending($this->option('with-pending'));
})
->cursor();
}
protected function withPending(): ?bool
{
return $this->option('with-pending') ? true : null;
}
public function __construct()
{
parent::__construct();