You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.8 KiB

3 years ago
  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. use PhpSchool\CliMenu\Builder\CliMenuBuilder;
  6. use PhpSchool\CliMenu\CliMenu;
  7. class AdminLogsCommand extends Command
  8. {
  9. /**
  10. * The signature of the command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'admin:logs';
  15. /**
  16. * The description of the command.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Command description';
  21. /**
  22. *
  23. *
  24. */
  25. private function addInputItem()
  26. {
  27. $callable = function(CliMenu $menu)
  28. {
  29. $input = $menu->askText();
  30. $result = $input->ask();
  31. $menu->redraw();
  32. };
  33. return $callable;
  34. }
  35. /**
  36. *
  37. *
  38. */
  39. private function addCreateItem()
  40. {
  41. $menu = function(CliMenuBuilder $builder)
  42. {
  43. $data = [];
  44. $builder
  45. ->setTitle('Settings > Add')
  46. ->disableDefaultItems()
  47. // input name
  48. ->addItem('name', $this->addInputItem())
  49. // input url
  50. ->addItem('url', $this->addInputItem())
  51. ->addItem('handler', $this->addInputItem())
  52. ->addLineBreak('-')
  53. ->addSubMenu('actions', $this->addActions())
  54. ->addLineBreak('-');
  55. };
  56. return $menu;
  57. }
  58. /**
  59. * Execute the console command.
  60. *
  61. * @return mixed
  62. */
  63. public function handle()
  64. {
  65. // create menu
  66. $builder = $this->menu('Settings');
  67. $builder
  68. ->addSubMenu('Add', $this->addCreateItem())
  69. ->addLineBreak('-');
  70. $mainmenu = $builder->build();
  71. $mainmenu->open();
  72. }
  73. }