kphcdr 1 year ago
parent
commit
a7770f3e46

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

@@ -30,7 +30,10 @@ class TestCommand extends Command
     {
         $cartesianProduct = new CartesianProduct();
         $cartesianProduct->appendSet(["a"]);
-        $cartesianProduct->appendSet(['b', 'c']);
-        dd($cartesianProduct->compute());
+        dump($cartesianProduct->compute());
+        $cartesianProduct = new CartesianProduct();
+        $cartesianProduct->appendSet(["a"]);
+        $cartesianProduct->appendSet(["b"]);
+        dump($cartesianProduct->compute());
     }
 }

+ 3 - 1
app/Modules/Admin/Services/SpecService.php

@@ -97,7 +97,9 @@ class SpecService extends BaseService
     public function cartesian(array $specIdArr)
     {
         $specS = Spec::with("attrs")->whereIn("id", $specIdArr)->where("is_custom", 0)->get();
-
+        if ($specS->isEmpty()) {
+            return [];
+        }
         $attrS = collect();
         $cartesianProduct = new CartesianProduct();
         foreach ($specS as $spec) {