Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/DomainList.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use App\Console\Command; | |||||
use App\Domain; | use App\Domain; | ||||
use Illuminate\Console\Command; | |||||
class DomainList extends Command | class DomainList extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'domain:list {--deleted}'; | protected $signature = 'domain:list {--deleted}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'List domains'; | protected $description = 'List domains'; | ||||
/** | /** | ||||
* Create a new command instance. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function __construct() | |||||
{ | |||||
parent::__construct(); | |||||
} | |||||
/** | |||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
if ($this->option('deleted')) { | if ($this->option('deleted')) { | ||||
$domains = Domain::withTrashed()->orderBy('namespace'); | $domains = Domain::withTrashed()->orderBy('namespace'); | ||||
} else { | } else { | ||||
$domains = Domain::orderBy('namespace'); | $domains = Domain::orderBy('namespace'); | ||||
} | } | ||||
$domains->each( | $domains->withEnvTenant()->each( | ||||
function ($domain) { | function ($domain) { | ||||
$msg = $domain->namespace; | $msg = $domain->namespace; | ||||
if ($domain->deleted_at) { | if ($domain->deleted_at) { | ||||
$msg .= " (deleted at {$domain->deleted_at})"; | $msg .= " (deleted at {$domain->deleted_at})"; | ||||
} | } | ||||
$this->info($msg); | $this->info($msg); | ||||
} | } | ||||
); | ); | ||||
} | } | ||||
} | } |