Replicate Laravel collection - Laravel 5.3
<p>Im replicating a trips table. On the trips form, there is a dropdown to select species. A user can select many species to. Im having trouble replicating this species table beacuse its in its own table, and its a collection. So using "replicate" wont work.</p>

<p>This is how Im replicating the trips table right now:</p>

<pre><code>public function replicateTrip (Request $request, $slug, $id) {

        $listing = $request-&gt;user()-&gt;listings()-&gt;where('slug', $slug)-&gt;first();
        $trip = $listing-&gt;trips()-&gt;where('id', $id)-&gt;first();

        $replicateTrip = Trip::find($trip-&gt;id);
        // This is how im getting the species from the species table
        $replicateSpecies = DB::table('species_trip')-&gt;where('trip_id', $id)-&gt;get();

        $newTask = $replicateTrip-&gt;replicate();

        $newTask-&gt;save();

        return redirect()-&gt;back();

}
</code></pre>

<p>If I DD the $replicateSpecies variable when cloning my current trip, I get:</p>

<p><a href="https://i.stack.imgur.com/pBLlL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pBLlL.png" alt="My Collection"></a></p>

<p>I need to replicate the species array from my orginal trip into the species table, and I cant just use "replicate", because its a collection.</p>

<p>So my question is how would I replicate this collection? Or if there is another method of doing this?</p>