0
我試圖檢索多行,循環用foreach,和更新每一個特定值的那些行(基於開關)通過的foreach更新有着不同的價值觀多行 - Laravel雄辯
我得到的Method save does not exist
錯誤。不知道這個使用Eloquent的語法應該是什麼。
$appointmentreminders = Appointmentreminder::where('appointment_id', '=', $id)->get();
foreach ($appointmentreminders as $appointmentreminder)
{
switch ($appointmentreminder->timeunit) {
case "minute":
$reminder = clone($appointment->appointment_start);
$reminder->subMinutes($appointmentreminder->time);
break;
case "hour":
$reminder = clone($appointment->appointment_start);
$reminder->subHours($appointmentreminder->time);
break;
case "day":
$reminder = clone($appointment->appointment_start);
$reminder->subDays($appointmentreminder->time);
break;
case "week":
$reminder = clone($appointment->appointment_start);
$reminder->subWeeks($appointmentreminder->time);
break;
case "month":
$reminder = clone($appointment->appointment_start);
$reminder->subMonths($appointmentreminder->time);
break;
}
$appointmentreminders->reminder = $reminder;
$appointmentreminders->save();
}
完美的作品!謝謝@Komal – user3489502
歡迎:)感謝您接受我的答案 – Komal