123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Console\Commands;
- use App\Models\Goods\Goods;
- use App\Modules\Admin\Services\GoodsService;
- use Illuminate\Console\Command;
- use Nerd\CartesianProduct\CartesianProduct;
- class TestCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'test {cmd?}';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Command description';
- public function handle()
- {
- $cmd = $this->argument('cmd');
- $args = $this->arguments();
- unset($args['command'], $args['cmd']);
- $params = array_values($args);
- if (empty($cmd)) {
- echo 'Nothing to do...';
- } else {
- if (method_exists($this, $cmd)) {
- call_user_func_array([$this, $cmd], $params);
- } else {
- echo 'cmd not exists';
- }
- }
- return;
- }
- public function time()
- {
- $cartesianProduct = new CartesianProduct();
- $cartesianProduct->appendSet(["红色", "白色"]);
- dump($cartesianProduct->compute());
- }
- public function search()
- {
- Goods::chunk(100, function ($goods) {
- $goods->each(function (Goods $g) {
- app(GoodsService::class)->createIndex($g);
- });
- });
- }
- }
|