I have a problem with replicating one of my models with all the relationships.
The database structure is as follows:
Table1: products id name Table2
$product = Product::with('options')->find($id); $new_product = $product->replicate(); $new_product->{attribute} = {value}; $new_product->push(); $new_product->options()->saveMany($product->options);