title: How to duplicate a record with your relationships in Laravel 8?
body: <p>I've tried several things I've searched for on the web but I still haven't had success, there's a lot of content for previous versions of Laravel, but for 8 I haven't found it.</p>
  <p>I tried to do this, but without success.</p>
  <pre><code>    public function DuplicateList($idList)
      {
          $getList = Accompaniment::with(['categoryAccompaniments', 'categoryAccompaniments.additionals'])-&gt;find($idList);
          $newList = $getList-&gt;replicate();
          $newList-&gt;push();
  
          foreach($getList-&gt;categoryAccompaniments as $categoryAccompaniment)
          {
              $newList-&gt;categoryAccompaniments()-&gt;attach($categoryAccompaniment);
          }
  
      }
  </code></pre>