我使用多对多的关系。我想为这个属性设置两个值。Laravel多对多
产品,
属性,
attribute_product =>product_id,attribute_id,value
我知道这是错的,但我想告诉你,我想
$product->attributes()->sync([
1 => [
'value' => 'sky'
],
1 => [
'value' => 'night'
],
]);
更新2
Schema::create('attribute_product', function (Blueprint $table) {
$table->unsignedInteger('product_id');
$table->unsignedInteger('attribute_id');
$table->text('value')->nullable();
$table->integer('devalue_id')->nullable(); // value id
$table->primary(['product_id', 'attribute_id', 'devalue_id']);
});
更新1
我需要设置的天空,晚上
product_id attribute_id value devalue_id
1 1 sky 1
1 1 night 2
...
请您重新说明一下吗? –
@ImAtWar https://www.digikala.com/Product/DKP-149283此笔记本电脑具有多个attributs值: –
用法:多媒体,窄和光。它如何保存这个值 –