-
Couldn't load subscription status.
- Fork 4
Copy method
Benyamin Khalife edited this page May 20, 2024 · 1 revision
In cases where we need to record a copy of the value of a row as a new record, we can use the copy method
$trade = Trade::find(104); $new_trade = Trade::copy($trade); $new_trade->user_id = $new_user_id; $new_trade->save()In the example above, we first received the desired data and created a copy of it in $new_trade, and then changed its user_id field and registered the new record.
This method copies the values of all fields except for created_at and updated_at, and if needed, you can change the information of each field first and then save it.