From: Vincent Vanwaelscappel Date: Thu, 6 Jun 2019 17:35:39 +0000 (+0200) Subject: #2810 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3a64844e9cbb1b2eaa8ac37783f0734d1763bc2e;p=pmi.git #2810 --- diff --git a/app/Models/Product.php b/app/Models/Product.php index e18cb3f..dbb4a3c 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -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') {