. */ namespace App\Console\Commands; use Illuminate\Console\Command; use App\Account; class SetAccountAdmin extends Command { protected $signature = 'accounts:set-admin {id}'; protected $description = 'Give the admin role to an account'; public function __construct() { parent::__construct(); } public function handle() { $account = Account::withoutGlobalScopes()->where('id', $this->argument('id'))->first(); if (!$account) { $this->error('Account not found, please use an existing account id'); return 1; } if ($account->admin) { $this->error('The account is already having the admin role'); return 1; } $account->admin = true; $account->save(); $this->info('Account '.$account->identifier.' is now admin'); return 0; } }