argument('name'); $error = $this->validateName($name); if ($error) { $this->error($error); return; } $key = ApiKey::where('name', $name)->first(); if (!$key->active) { $this->info('Key "' . $name . '" is already deactivated'); return; } $key->active = 0; $key->save(); $this->info('Deactivated key: ' . $name); } /** * Validate name * * @param string $name * @return string */ protected function validateName($name) { if (!ApiKey::isValidName($name)) { return self::MESSAGE_ERROR_INVALID_NAME; } if (!ApiKey::nameExists($name)) { return self::MESSAGE_ERROR_NAME_DOES_NOT_EXIST; } return null; } }