TestCommand.php 996 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Nerd\CartesianProduct\CartesianProduct;
  5. class TestCommand extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'test {cmd?}';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'Command description';
  19. public function handle()
  20. {
  21. $cmd = $this->argument('cmd');
  22. $args = $this->arguments();
  23. unset($args['command'], $args['cmd']);
  24. $params = array_values($args);
  25. if (empty($cmd)) {
  26. echo 'Nothing to do...';
  27. } else {
  28. if (method_exists($this, $cmd)) {
  29. call_user_func_array([$this, $cmd], $params);
  30. } else {
  31. echo 'cmd not exists';
  32. }
  33. }
  34. return;
  35. }
  36. public function time()
  37. {
  38. dump(date('Y-m-d H:i:s'));
  39. }
  40. }