diff --git a/src/BotDetectCaptcha.php b/src/BotDetectCaptcha.php index 9dbe751..808d10e 100644 --- a/src/BotDetectCaptcha.php +++ b/src/BotDetectCaptcha.php @@ -15,7 +15,7 @@ class BotDetectCaptcha /** * @var object */ - private static $instance; + private static $instances = []; /** * BotDetect Laravel CAPTCHA package information. @@ -32,7 +32,7 @@ class BotDetectCaptcha */ public function __construct($configName, $captchaInstanceId = null) { - self::$instance = $this; + self::$instances[$configName] = $this; // load BotDetect Library LibraryLoader::load(); @@ -79,9 +79,9 @@ public function initCaptcha(array $config, $captchaInstanceId = null) * * @return object */ - public static function getInstance() + public static function getInstance($configName) { - return self::$instance; + return array_key_exists($configName, self::$instances) ? self::$instances[$configName] : null; } public function __call($method, $args = array()) diff --git a/src/Support/helpers.php b/src/Support/helpers.php index beaa99f..aa49502 100644 --- a/src/Support/helpers.php +++ b/src/Support/helpers.php @@ -69,7 +69,7 @@ function captcha_library_is_loaded() */ function captcha_instance($captchaId) { - $captcha = BotDetectCaptcha::getInstance(); + $captcha = BotDetectCaptcha::getInstance($captchaId); return (null !== $captcha) ? $captcha : new BotDetectCaptcha($captchaId); } }