mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 21:34:03 +00:00
Remove obsolete files, restructure
This commit is contained in:
parent
fbe43fbb04
commit
4f8d892481
20 changed files with 19 additions and 83 deletions
35
src/Concerns/HasATenantsOption.php
Normal file
35
src/Concerns/HasATenantsOption.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Concerns;
|
||||
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
trait HasATenantsOption
|
||||
{
|
||||
protected function getOptions()
|
||||
{
|
||||
return array_merge([
|
||||
['tenants', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, '', null],
|
||||
], parent::getOptions());
|
||||
}
|
||||
|
||||
protected function getTenants(): LazyCollection
|
||||
{
|
||||
return tenancy()
|
||||
->query()
|
||||
->when($this->option('tenants'), function ($query) {
|
||||
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
|
||||
})
|
||||
->cursor();
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->specifyParameters();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue