From 71adfd2804513d12a19171de9f1c90e0a6c04fcf Mon Sep 17 00:00:00 2001 From: Daniel Supernault <danielsupernault@gmail.com> Date: Wed, 5 Jun 2024 22:48:58 -0600 Subject: [PATCH] Add app:captcha-toggle-command command to disable captcha from cli --- app/Console/Commands/CaptchaToggleCommand.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 app/Console/Commands/CaptchaToggleCommand.php diff --git a/app/Console/Commands/CaptchaToggleCommand.php b/app/Console/Commands/CaptchaToggleCommand.php new file mode 100644 index 00000000..e4f43f52 --- /dev/null +++ b/app/Console/Commands/CaptchaToggleCommand.php @@ -0,0 +1,52 @@ +<?php + +namespace App\Console\Commands; + +use Illuminate\Console\Command; +use function Laravel\Prompts\info; +use function Laravel\Prompts\confirm; +use App\Services\ConfigCacheService; + +class CaptchaToggleCommand extends Command +{ + /** + * The name and signature of the console command. + * + * @var string + */ + protected $signature = 'app:captcha-toggle-command'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Command description'; + + /** + * Execute the console command. + */ + public function handle() + { + $captchaEnabled = (bool) config_cache('captcha.enabled'); + + info($captchaEnabled ? 'Captcha is enabled' : 'Captcha is not enabled'); + + if(!$captchaEnabled) { + info('Enable the Captcha from the admin settings dashboard.'); + return; + } + + $confirmed = confirm( + label: 'Do you want to disable the captcha?', + default: false, + yes: 'Yes', + no: 'No', + hint: 'Select an option to proceed.' + ); + + if($confirmed) { + ConfigCacheService::put('captcha.enabled', false); + } + } +}