diff --git a/src/CaptchaFactory.php b/src/CaptchaFactory.php deleted file mode 100644 index 271fe13..0000000 --- a/src/CaptchaFactory.php +++ /dev/null @@ -1,49 +0,0 @@ -config = $config; - } - - /** - * Make a captcha service based on the configuration. - * - * - * @throws \Rahul900day\Captcha\Exceptions\InvalidCaptchaDriverException - */ - public function make(): Captcha - { - $driver = $this->config['driver']; - - switch ($driver) { - case 'hCaptcha': - return new HCaptcha(); - case 'reCaptcha': - return new ReCaptcha(); - case 'turnstile': - return new TurnstileCaptcha(); - default: - throw new InvalidCaptchaDriverException($driver); - } - } -} diff --git a/src/CaptchaManager.php b/src/CaptchaManager.php new file mode 100644 index 0000000..e88c069 --- /dev/null +++ b/src/CaptchaManager.php @@ -0,0 +1,36 @@ +app->singleton(CaptchaContract::class, function ($app) { - return (new CaptchaFactory(config('captcha')))->make(); + return new CaptchaManager($app); }); } diff --git a/src/Drivers/FakeCaptcha.php b/src/Drivers/FakeCaptcha.php index eb1c273..8a8a0d6 100644 --- a/src/Drivers/FakeCaptcha.php +++ b/src/Drivers/FakeCaptcha.php @@ -31,7 +31,7 @@ public function getJs(?string $hl): string input.setAttribute('type', 'hidden'); input.setAttribute('name', '{$this->getResponseName()}') input.setAttribute('value', 'pass') - container.appendChild(input) + container.parentElement.appendChild(input) }) HTML;