for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Console\Commands;
use App\User;
use Illuminate\Console\Command;
class DestroyUserCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'user:destroy {id? : The user id}';
* The console command description.
protected $description = 'This command destroy an existing user by id';
* Create a new command instance.
* @return void
public function __construct()
parent::__construct();
}
* Execute the console command.
* @return mixed
public function handle()
try {
$id = $this->argument('id') ? $this->argument('id') : $this->ask('User id?');
$count = User::destroy($id);
} catch (Exception $e) {
App\Console\Commands\Exception
Exception
\
$this->error('error'.$e);
if ($count == 0) {
$count
$this->alert('User does not exist');
} else {
$this->info('User has been deleted to database succesfully');