namespace App\Models;
use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+use Cubist\Util\ObjectUtil;
use Illuminate\Support\Str;
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') {