mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 23:54:04 +00:00
* Fix tenants:list when not using multi-domain tenancy * formatting * update to an if/else
45 lines
1,021 B
PHP
45 lines
1,021 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Stancl\Tenancy\Contracts\Tenant;
|
|
|
|
class TenantList extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'tenants:list';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'List tenants.';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->info('Listing all tenants.');
|
|
tenancy()
|
|
->query()
|
|
->cursor()
|
|
->each(function (Tenant $tenant) {
|
|
if ($tenant->domains) {
|
|
$this->line("[Tenant] id: {$tenant['id']} @ " . implode('; ', $tenant->domains->pluck('domain')->toArray() ?? []));
|
|
} else {
|
|
$this->line("[Tenant] id: {$tenant['id']}");
|
|
}
|
|
});
|
|
}
|
|
}
|