Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/UserForceDelete.php
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands; | ||||
use Illuminate\Console\Command; | use App\Console\Command; | ||||
use Illuminate\Support\Facades\DB; | use Illuminate\Support\Facades\DB; | ||||
class UserForceDelete extends Command | class UserForceDelete extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
Show All 9 Lines | class UserForceDelete 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 = $this->getUser($this->argument('user'), true); | ||||
if (!$user) { | if (!$user) { | ||||
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->forceDelete(); | $user->forceDelete(); | ||||
DB::commit(); | DB::commit(); | ||||
} | } | ||||
} | } |