Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/DomainRestore.php
- This file was added.
<?php | |||||
namespace App\Console\Commands; | |||||
use Illuminate\Console\Command; | |||||
use Illuminate\Support\Facades\DB; | |||||
class DomainRestore extends Command | |||||
{ | |||||
/** | |||||
* The name and signature of the console command. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $signature = 'domain:restore {domain}'; | |||||
/** | |||||
* The console command description. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $description = 'Restore (undelete) a domain'; | |||||
/** | |||||
* Execute the console command. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function handle() | |||||
{ | |||||
$domain = \App\Domain::withTrashed()->where('namespace', $this->argument('domain'))->first(); | |||||
if (!$domain) { | |||||
$this->error("Domain not found."); | |||||
return 1; | |||||
} | |||||
if (!$domain->trashed()) { | |||||
$this->error("The domain is not yet deleted."); | |||||
return 1; | |||||
} | |||||
$wallet = $domain->wallet(); | |||||
if ($wallet && !$wallet->owner) { | |||||
vanmeeuwen: I don't understand this part.
When `john@kolab.org` deletes itself and needs to be restored… | |||||
machniakAuthorUnsubmitted Done Inline ActionsIt's just that you cannot restore a domain before restoring the user. But the command is still useful if you restore a domain (one of many) on an existing account. machniak: It's just that you cannot restore a domain before restoring the user. But the command is still… | |||||
$this->error("The domain owner is deleted."); | |||||
return 1; | |||||
} | |||||
DB::beginTransaction(); | |||||
$domain->restore(); | |||||
DB::commit(); | |||||
} | |||||
} |
I don't understand this part.
When john@kolab.org deletes itself and needs to be restored, is the situation not always that both the User as well as the Domain are deleted?
Does it then mandate that first user:restore john@kolab.org is ran?