mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 14:54:03 +00:00
Using laravel components
This commit is contained in:
parent
6ee93d0441
commit
2f15dd5473
10 changed files with 142 additions and 59 deletions
|
|
@ -16,17 +16,40 @@ class TenantList extends Command
|
|||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Listing all tenants.');
|
||||
|
||||
$tenants = tenancy()->query()->cursor();
|
||||
|
||||
$this->components->info("Listing {$tenants->count()} tenants.");
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
/** @var Model&Tenant $tenant */
|
||||
if ($tenant->domains) {
|
||||
$this->line("[Tenant] {$tenant->getTenantKeyName()}: {$tenant->getTenantKey()} @ " . implode('; ', $tenant->domains->pluck('domain')->toArray() ?? []));
|
||||
} else {
|
||||
$this->line("[Tenant] {$tenant->getTenantKeyName()}: {$tenant->getTenantKey()}");
|
||||
}
|
||||
$this->components->twoColumnDetail($this->tenantCli($tenant), $this->domainsCli($tenant));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the visual cli output for the tenant name
|
||||
*
|
||||
* @param Model $tenant
|
||||
* @return string
|
||||
*/
|
||||
protected function tenantCli(Model $tenant): string
|
||||
{
|
||||
return "<fg=yellow>{$tenant->getTenantKeyName()}: {$tenant->getTenantKey()}</>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the visual cli output for the domain names
|
||||
*
|
||||
* @param Model $tenant
|
||||
* @return string|null
|
||||
*/
|
||||
protected function domainsCli(Model $tenant): ?string
|
||||
{
|
||||
if (is_null($tenant->domains)){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return "<fg=blue;options=bold>{$tenant->domains->pluck('domain')->implode(' ; ')}</>";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue