Hi, I got a question regarding copying a model with all relations. I got a model with multiple relations, and those relations also have relations. Is there a way I can literally copy all those models, as new instances?
To get a clearer image, here is some pseudocode:
$test = Test::Find($id); $test->testobjects->testgroup->id; //returns 1 for instance //I want to also copy all relations automatically $testCopy = new Test($test); $testCopy->testobjects->testgroup->id //returns 2 for instance
Is there a smart way to do this copy action? Thanks in advance!