Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/User/RestoreCommand.php
- This file was moved from src/app/Console/Commands/UserRestore.php.
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands\User; | ||||
use App\Console\Command; | use App\Console\Command; | ||||
use Illuminate\Support\Facades\DB; | use Illuminate\Support\Facades\DB; | ||||
class UserRestore extends Command | class RestoreCommand extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'user:restore {user}'; | protected $signature = 'user:restore {user}'; | ||||
Show All 9 Lines | class RestoreCommand extends Command | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$user = $this->getUser($this->argument('user'), true); | $user = $this->getUser($this->argument('user'), true); | ||||
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 deleted."); | ||||
return 1; | return 1; | ||||
} | } | ||||
DB::beginTransaction(); | DB::beginTransaction(); | ||||
$user->restore(); | $user->restore(); | ||||
DB::commit(); | DB::commit(); | ||||
} | } | ||||
} | } |