title: Laravel Eloquent ORM replicate
body: <p>I have a problem with replicating one of my models with all the relationships.</p>
  
  <p>The database structure is as follows:</p>
  
  <pre><code>Table1: products
  id
  name
  
  Table2: product_options
  id
  product_id
  option
  
  Table3: categories
  id
  name
  
  Pivot table: product_categories
  product_id
  category_id
  </code></pre>
  
  <p>Relationships are: </p>
  
  <ul>
  <li>product hasMany product_options</li>
  <li>product belongsToMany category (trough product_categories)</li>
  </ul>
  
  <p>I would like to clone a product with all the relationships. Currently here is my code:</p>
  
  <pre><code>$product = Product::with('options')-&gt;find($id);
  $new_product = $product-&gt;replicate();
  $new_product-&gt;push();
  foreach($product-&gt;options as $option){
      $new_option = $option-&gt;replicate();
      $new_option-&gt;product_id = $new_product-&gt;id;
      $new_option-&gt;push();
  }
  </code></pre>
  
  <p>But this does not works (the relationships are not cloned - currently I just tried to clone the product_options).</p>