title: Laravel Eloquent update related records
body: <p>I have two mysql tables</p>
  <pre><code>1. sales (id,buyer_id)
  2. sales_items (id,sales_id,item_id,price,quantity)
  </code></pre>
  <p>very simple two tables.
  I am having issue while want to update any record,
  like when I edit some sales record I can</p>
  <ol>
  <li>add new item</li>
  <li>modify previously added item</li>
  <li>or delete previously added item</li>
  </ol>
  <p>Now I want to update sales_items tables also.</p>
  <p>What I am doing now is</p>
  <blockquote>
  <ol>
  <li>first deleting all records of sales in sales_items table</li>
  <li>Add new records</li>
  </ol>
  </blockquote>
  <pre><code>$task = Auth::user()-&gt;sales_items()-&gt;where(['sales_id'=&gt;1]);
  $task-&gt;delete();
  
  //$SalesProducts array have all rows
  SaleItem::insert($SalesProducts);
  </code></pre>
  <p>code is working but is this correct approach or there is batter way to do that?
  I am using Laravel 8 Eloquent and all tables have models</p>
  <p>Thanks</p>