Chrisbjr\ApiGuard\Console\Commands\DeleteApiKeyCommand::fire PHP Method

fire() public method

Execute the console command.
public fire ( ) : mixed
return mixed
    public function fire()
    {
        $key = $this->option('api-key');
        if (!is_null($key)) {
            // we delete a specific API key
            $confirmation = $this->ask("Are you sure you want to delete this API key? [y/n]");
            if ($confirmation == 'y') {
                $apiKeyModel = App::make(Config::get('apiguard.models.apiKey', 'Chrisbjr\\ApiGuard\\Models\\ApiKey'));
                $apiKey = $apiKeyModel->where('key', '=', $key)->first();
                if (empty($apiKey) || $apiKey->exists == false) {
                    $this->info("The API key you specified does not exist.");
                    return;
                }
                $apiKey->delete();
                $this->info("The API key {$key} was deleted.");
                return;
            }
            return;
        }
        $this->error("Specify an API key to delete using the --api-key option. Example: --api-key=xxxxxxxxx");
    }