/** * Execute the console command. * * @return mixed */ public function handle() { if ($this->confirm('Do you want list the existing roles? [y|N]')) { $headers = ['Name', 'Level']; $roles = $this->roleCommand->getAll(['name', 'level'])->toArray(); $this->table($headers, $roles); } $name = $this->ask('Which role do you want to delete ?'); if ($this->confirm('Do you wish to continue? [y|N]')) { $this->roleCommand->delete($name); } }
/** * @throws Exception */ public function handle() { $action = $this->argument('action'); $roles = Config::get('roles.basic'); try { switch (trim($action)) { case 'C': foreach ($roles as $roleName => $role) { $this->roleCommand->create($roleName, $role['level'], $role['description']); } break; case 'D': foreach (array_keys($roles) as $roleName) { $this->roleCommand->delete($roleName); } break; } } catch (Exception $e) { $this->error($e->getMessage()); } }