/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $userId = $this->getOption('user-id', null);
     if (!empty($userId)) {
         // check whether this user already has an API key
         $apiKeyModel = App::make(Config::get('apiguard.models.apiKey', 'Chrisbjr\\ApiGuard\\Models\\ApiKey'));
         $apiKey = $apiKeyModel->where('user_id', '=', $userId)->first();
         if ($apiKey) {
             $overwrite = $this->ask("This user already has an existing API key. Do you want to create another one? [y/n]");
             if ($overwrite == 'n') {
                 return;
             }
         }
     }
     $apiKey = ApiKey::make($this->getOption('user-id', null), $this->getOption('level', 10), $this->getOption('ignore-limits', 1));
     if (empty($apiKey->user_id)) {
         $this->info("You have successfully generated an API key:");
     } else {
         $this->info("You have successfully generated an API key for user ID#{$apiKey->user_id}:");
     }
     $this->info($apiKey->key);
 }
 /**
  * @param User $user
  *
  * @return mixed
  */
 private function createUserApiKey(User $user)
 {
     $apiKey = ApiKey::make($user->id);
     $user->apiKey()->save($apiKey);
 }