【发布时间】:2021-06-20 08:20:50
【问题描述】:
我正在开发一个 laravel 项目并试图在 mysql db 中复制一条记录。 复制后,我想将字段值设置为 null(appointment_status)。 一切正常,除了新记录的值 (appointment_status) 与原始记录相同,即使我将其设置为 null。
$newAppointment = $appointment->replicate();
//push to get the id for the cloned record
$newAppointment->push();
$newAppointment->duplicated_from_id = $appointment->id;
$newAppointment->appointment_status = null;
$newAppointment->save();
//updating the old appointment
$appointment->duplicated_to_id = $newAppointment->id;
$appointment->save();
【问题讨论】: