diff --git a/src/app/Console/Commands/DomainAdd.php b/src/app/Console/Commands/DomainAdd.php index 884a0552..fbc8d0e4 100644 --- a/src/app/Console/Commands/DomainAdd.php +++ b/src/app/Console/Commands/DomainAdd.php @@ -1,75 +1,76 @@ argument('domain')); // must use withTrashed(), because unique constraint $domain = Domain::withTrashed()->where('namespace', $namespace)->first(); if ($domain && !$this->option('force')) { $this->error("Domain {$namespace} already exists."); return 1; } Queue::fake(); // ignore LDAP for now if ($domain) { if ($domain->deleted_at) { // revive domain $domain->deleted_at = null; $domain->status = 0; $domain->save(); // remove existing entitlement $entitlement = Entitlement::withTrashed()->where( [ 'entitleable_id' => $domain->id, 'entitleable_type' => \App\Domain::class ] )->first(); if ($entitlement) { $entitlement->forceDelete(); } } else { $this->error("Domain {$namespace} not marked as deleted... examine more closely"); return 1; } } else { $domain = Domain::create([ 'namespace' => $namespace, 'type' => Domain::TYPE_EXTERNAL, ]); } $this->info($domain->id); } }