CaptchaToggleCommand.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use function Laravel\Prompts\info;
  5. use function Laravel\Prompts\confirm;
  6. use App\Services\ConfigCacheService;
  7. class CaptchaToggleCommand extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'app:captcha-toggle-command';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Command description';
  21. /**
  22. * Execute the console command.
  23. */
  24. public function handle()
  25. {
  26. $captchaEnabled = (bool) config_cache('captcha.enabled');
  27. info($captchaEnabled ? 'Captcha is enabled' : 'Captcha is not enabled');
  28. if(!$captchaEnabled) {
  29. info('Enable the Captcha from the admin settings dashboard.');
  30. return;
  31. }
  32. $confirmed = confirm(
  33. label: 'Do you want to disable the captcha?',
  34. default: false,
  35. yes: 'Yes',
  36. no: 'No',
  37. hint: 'Select an option to proceed.'
  38. );
  39. if($confirmed) {
  40. ConfigCacheService::put('captcha.enabled', false);
  41. }
  42. }
  43. }