2021-06-17 14:08:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
2022-06-26 14:14:36 +00:00
|
|
|
class UserMakeAdmin extends Command
|
2021-06-17 14:08:30 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2022-06-26 14:14:36 +00:00
|
|
|
protected $signature = 'user:make:admin {email : User Email}';
|
2021-06-17 14:08:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Make a user a system admin';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$o = User::where('email',$this->argument('email'))->firstOrfail();
|
|
|
|
$o->admin = ! $o->admin;
|
|
|
|
$o->save();
|
|
|
|
|
|
|
|
$this->info(sprintf('User [%s] %s an admin',$o->email,$o->admin ? 'IS' : 'is NOT'));
|
|
|
|
}
|
|
|
|
}
|