Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/DomainDelete.php
- This file was copied from src/app/Console/Commands/DomainList.php.
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use App\Domain; | |||||
use Illuminate\Console\Command; | use Illuminate\Console\Command; | ||||
class DomainList extends Command | class DomainDelete 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'; | protected $signature = 'domain:delete {domain}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'List domains'; | protected $description = 'Delete a domain'; | ||||
/** | /** | ||||
* Create a new command instance. | * Create a new command instance. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
parent::__construct(); | parent::__construct(); | ||||
} | } | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$domains = Domain::withTrashed()->orderBy('namespace')->each( | $domain = \App\Domain::where('id', $this->argument('domain'))->first(); | ||||
function ($domain) { | |||||
$this->info($domain->namespace); | if (!$domain) { | ||||
return 1; | |||||
} | } | ||||
); | |||||
$domain->delete(); | |||||
} | } | ||||
} | } |