. */ namespace App\Console\Commands\Spaces; use App\Space; use Illuminate\Console\Command; class CreateUpdate extends Command { protected $signature = 'spaces:create-update {sip_domain} {host} {--super}'; protected $description = 'Create a Space'; public function handle() { $this->info('Your will create or update a Space in the database'); $space = Space::where('domain', $this->argument('sip_domain'))->firstOrNew(); $space->host = $this->argument('host'); $space->domain = $this->argument('sip_domain'); $space->exists ? $this->info('The domain already exists, updating it') : $this->info('A new domain will be created'); $space->super = (bool)$this->option('super'); $space->super ? $this->info('Set as a super domain') : $this->info('Set as a normal domain'); $space->save(); return Command::SUCCESS; } }