]> _ Git - pmi.git/commitdiff
#2810
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2019 17:35:39 +0000 (19:35 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2019 17:35:39 +0000 (19:35 +0200)
app/Models/Product.php

index e18cb3f04fd6359ab63ab40a72cf2b54bffb835b..dbb4a3c82de7e61c0c90d8986f05813bc164fb7f 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Models;
 
 use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+use Cubist\Util\ObjectUtil;
 use Illuminate\Support\Str;
 
 class Product extends CubistMagicModel
@@ -35,15 +36,26 @@ class Product extends CubistMagicModel
             'type' => 'SelectFromModel',
             'model' => 'App\Models\ProductType',
             'column' => true,
-            'tab' => 'General']);
+            'tab' => 'Specifications']);
 
         $specifications = Specification::all();
+        $types = ProductType::all();
         foreach ($specifications as $spec) {
+            $in = [];
+            foreach ($types as $type) {
+                foreach ($type->specifications as $rel_specification) {
+                    if ($spec->id == $rel_specification->id) {
+                        $in[] = $type->id;
+                        break;
+                    }
+                }
+            }
             $params = ['tab' => 'Specifications',
                 'name' => 's_' . Str::snake($spec->name),
                 'label' => $spec->name,
                 'fake' => true,
                 'store_in' => 'specifications',
+                'when' => ['product_type' => $in],
             ];
 
             if ($spec->type == 'numeric') {