title: Laravel update one-to-many relationship
body: <p>I have a request that contains the next data</p>
  
  <pre><code>{
    "path": "some path",
    "site_link": "http://example.com"  
    "features": [ ... ] //array of strings
  }
  </code></pre>
  
  <p>I wish to update my two tables <code>site</code> and <code>site features</code>.</p>
  
  <p><code>site</code> table contains <code>| id | path | site_link |</code>.</p>
  
  <p>And <code>site features</code> these <code>| id | feature | site_id |</code>
  I don't know exact amount of "features" however I need to update them after request.</p>
  
  <p>Is there any way to update them <strong>except</strong> for delete and then create once again. (some features may be changed, some be deleted and be added).</p>
  
  <p>For now I don't have any code for updating features. Only this</p>
  
  <pre><code>public function update(Request $request, Site $site)
      {
          $site-&gt;update([
              "path" =&gt; $request-&gt;path,
              "site_link" =&gt; $request-&gt;link
          ]);
  
          return response()-&gt;json($site, 200);
      }
  </code></pre>