Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
creates a clone of a model and his relationships
<?php namespace App\Http\Controllers;
use App\MyModel;
class CloneController extends Controller
{
/**
* Replicate a model and his relationships
*
* @param $id
*/
public function clone($id)
{
$model = MyModel::find($id);
$clone = $model->replicate();
$clone->push();
return $clone;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment