1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 23:54:04 +00:00
tenancy/src/Commands/TenantList.php
Pete Cooper dd1b7fc86d
Fix tenants:list when not using multi-domain tenancy (#504)
* Fix tenants:list when not using multi-domain tenancy

* formatting

* update to an if/else
2020-11-12 17:23:58 +01:00

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']}");
}
});
}
}