Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/DomainAdd.php
- This file was added.
<?php | |||||
namespace App\Console\Commands; | |||||
use App\Domain; | |||||
use Illuminate\Console\Command; | |||||
use Illuminate\Support\Facades\Queue; | |||||
class DomainAdd extends Command | |||||
{ | |||||
/** | |||||
* The name and signature of the console command. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $signature = 'domain:add {domain}'; | |||||
/** | |||||
* The console command description. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $description = "Create a domain."; | |||||
/** | |||||
* Execute the console command. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function handle() | |||||
{ | |||||
$namespace = \strtolower($this->argument('domain')); | |||||
$domain = Domain::where('namespace', $namespace)->first(); | |||||
if ($domain) { | |||||
$this->error("Domain already exists."); | |||||
return 1; | |||||
} | |||||
Queue::fake(); // ignore LDAP for now | |||||
$domain = Domain::create([ | |||||
'namespace' => $namespace, | |||||
'type' => Domain::TYPE_EXTERNAL, | |||||
]); | |||||
$this->info($domain->id); | |||||
} | |||||
} |