. */ namespace App\Console\Commands\Accounts; use Illuminate\Console\Command; use App\Account; class SetAdmin extends Command { protected $signature = 'accounts:set-admin {id}'; protected $description = 'Give the admin role to an account'; 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 Command::FAILURE; } if ($account->admin) { $this->error('The account is already having the admin role'); return Command::FAILURE; } $account->admin = true; $account->save(); $this->info('Account '.$account->identifier.' is now admin'); return Command::SUCCESS; } }