Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ogunlana Michael's avatar

How do I clone a data from one model to another

I have two tables, estimates, and invoices... I want to convert my estimate to an invoice... How do I go about it... I know the Laravel replicate helper that is just to duplicate itself, now from another model ......

0 likes
6 replies
jlrdw's avatar

You should be able to retrieve it get the data in an array and insert. Use one of the find techniques.

1 like
Snapey's avatar

Just write the code to copy one model to the other (and the relations). I'm not aware of any way to short cut it.

2 likes
Čamo's avatar

@Snapey Why not use replicate()??? I need to copy right now and search for some helper. Is there some problem with replicate()???

Please or to participate in this conversation.