J'utilise de nombreuses relations. Je veux définir deux valeurs pour cet attribut.Laravel multiple many to many
produit,
attributs,
attribute_product =>product_id,attribute_id,value
Je sais qu'il est mal, mais je veux vous montrer que je veux
$product->attributes()->sync([
1 => [
'value' => 'sky'
],
1 => [
'value' => 'night'
],
]);
Mise à jour 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']);
});
Update 1
je dois mettre le ciel, la nuit
product_id attribute_id value devalue_id
1 1 sky 1
1 1 night 2
...
Pourriez-vous, s'il vous plaît, reformuler? –
@ImAtWar https://www.digikala.com/Product/DKP-149283 Cet ordinateur portable a plusieurs valeur pour les attributs: –
utilisation: multimédia, étroit et léger. comment sauvegarde-t-il ces valeurs –