title: How can you update and create a new row in Laravel from a JSON object with relationships?
body: <p>I started using Laravel yesterday, the ORM seems powerful. Does it have any way of updating rows in related models? This is what I tried:</p>
  
  <p>Step 1: Generate a JSON object with the exact structure the database has. The JSON object has certain fields that are subarrays which represent relationships in the database.</p>
  
  <p>Step 2: Send the JSON object via POST to Laravel for processing, here it gets tricky:
  I can change the JSON object into an array first</p>
  
  <pre><code>$array = (array) $JSONobject;
  </code></pre>
  
  <p>Now I need to update, I would expect this to work:</p>
  
  <pre><code>Product::update($JSONobject-&gt;id,$array);
  </code></pre>
  
  <p>But because the array has subarrays, the update SQL that is executed cannot find the sub-array column in the table, it should instead look for the associated table. Can this be done? Or do I have to call the other models as well?</p>
  
  <p>Thanks in advance!</p>