Clone Your Eloquent Models

LaravelPosted on

Sometimes, it’s a nice feature to clone a model. If we need most of its attributes and change only a few, it could be life-saving. Using this one-liner we can clone the object easier than we except.

// You can deep copy your eloquent model
$new = $model->replicate();


Need a web developer? Maybe we can help, get in touch!

To see and write comments, you must allow the related (Disqus) cookies. For more information, please visit our privacy policy page.

Similar Posts

More content in Laravel category