Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/UserRestore.php
Show All 22 Lines | class UserRestore extends Command | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$user = \App\User::withTrashed()->where('email', $this->argument('user'))->first(); | $user = \App\User::withTrashed()->withEnvTenant() | ||||
->where('email', $this->argument('user'))->first(); | |||||
if (!$user) { | if (!$user) { | ||||
$this->error('User not found.'); | $this->error('User not found.'); | ||||
return 1; | return 1; | ||||
} | } | ||||
if (!$user->trashed()) { | if (!$user->trashed()) { | ||||
$this->error('The user is not yet deleted.'); | $this->error('The user is not yet deleted.'); | ||||
return 1; | return 1; | ||||
} | } | ||||
DB::beginTransaction(); | DB::beginTransaction(); | ||||
$user->restore(); | $user->restore(); | ||||
DB::commit(); | DB::commit(); | ||||
} | } | ||||
} | } |