From 3a64844e9cbb1b2eaa8ac37783f0734d1763bc2e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 6 Jun 2019 19:35:39 +0200 Subject: [PATCH] #2810 --- app/Models/Product.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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') { -- 2.39.5