TestCommand.php 1.1 KB

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