title: Laravel multiple many to many
body: <p>I am using many to many relation. i want to set two value for this attribute.</p>
  
  <p>product,</p>
  
  <p>attributes, </p>
  
  <p>attribute_product => <code>product_id,attribute_id,value</code></p>
  
  <p><a href="https://i.stack.imgur.com/v8E1J.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v8E1J.jpg" alt="enter image description here"></a></p>
  
  <p>I know it's wrong , but I want to show you that i want</p>
  
  <pre><code>$product-&gt;attributes()-&gt;sync([
              1 =&gt; [
                  'value' =&gt; 'sky'
              ],
              1 =&gt; [
                  'value' =&gt; 'night'
              ],
          ]);
  </code></pre>
  
  <p><strong>Update 2</strong></p>
  
  <pre><code>Schema::create('attribute_product', function (Blueprint $table) {
  
  $table-&gt;unsignedInteger('product_id');
  $table-&gt;unsignedInteger('attribute_id');
  $table-&gt;text('value')-&gt;nullable();
  $table-&gt;integer('devalue_id')-&gt;nullable(); // value id 
  
  $table-&gt;primary(['product_id', 'attribute_id', 'devalue_id']);
  
  });
  </code></pre>
  
  <p><strong>Update 1</strong></p>
  
  <p>I need to set sky,night </p>
  
  <pre><code>product_id  attribute_id      value       devalue_id
  1           1                 sky         1
  1           1                 night       2
  ...
  </code></pre>