title: How to update pivot table in laravel 8?
body: <p>I want to update pivot table in laravel 8 .I'm trynig sync method, but only insert first item of an array.</p>
  <p>Here is my code</p>
  <pre><code>         foreach ($products as $product) {
              $quantity        = $product['quantity'];
              $product_id      = $product['product_id'];
              $food_item_price = FoodItemPrice::where('food_item_id', $product_id)-&gt;first();
            
              $order-&gt;orderFoodItems()-&gt;sync([$product_id =&gt; [
                  'quantity'           =&gt; $quantity,
                  'food_item_price_id' =&gt; $food_item_price-&gt;id,
              ]]);
          }
  </code></pre>
  <p>In $products may have many products, but with sync method, it only updates first product. How to update pivot table properly?</p>