kphcdr hai 1 ano
pai
achega
9edb00be07
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      app/Console/Commands/TestCommand.php

+ 4 - 2
app/Console/Commands/TestCommand.php

@@ -51,8 +51,10 @@ class TestCommand extends Command
 
     public function search()
     {
-        Goods::get()->map(function (Goods $g) {
-            app(GoodsService::class)->createIndex($g);
+        Goods::chunk(100, function ($goods) {
+            $goods->each(function (Goods $g) {
+                app(GoodsService::class)->createIndex($g);
+            });
         });
     }
 }