title: Laravel save Eloquent along with relationships
body: <p>I added relations to a model. The structure being the following:</p>
  
  <blockquote>
    <p>A <code>Structure</code> Model <code>hasMany</code> <code>Managers</code>. Each <code>Manager</code> <code>hasMany</code> <code>Employees</code></p>
  </blockquote>
  
  <p>So I get this done using the following code:</p>
  
  <pre><code>$structure-&gt;name = "Something";
  $manager1 = new Manager;
  $manager2 = new Manager;
  
  $manager1-&gt;name = "Man One";
  $manager2-&gt;name = "Man Two";
  
  $emp1 = new Employee;
  $emp2 = new Employee;
  $emp3 = new Employee;
  
  $emp1-&gt;name....
  ...
  ....
  
  $manager1-&gt;add($emp1);
  $manager1-&gt;add($emp2);
  $manager2-&gt;add($emp3);
  
  $structure-&gt;add($manager1);
  $structure-&gt;add($manager2);
  
  .... //Some calculations &amp; necessary processing to fill up other properties of $structure.
  
  ///Now I have to save $structure..
  $structure-&gt;push()
  </code></pre>
  
  <p>But it returns an error that <code>$manager</code> needs value of foreign key (<code>structure_id</code>) for obvious reasons. <code>$structure-&gt;managers()-&gt;save()</code> does help but saving all the <strong>relations and their relations</strong> is cumbersome.</p>
  
  <p>Hence I need to know the method of saving the whole structure model at once.</p>