0
我打電話了以下功能Laravel功能不更新數據庫
function makeanote($type,$id){
$note = Notification::where("user_id",Auth::user()->id)->get();
if ($type == "user"){
if($id > $note->pluck("users")){
$note->users = $id;
$note->save();
return;
}
}
return;
}
像這樣:makeanote($type,$id)
。致電$type
是"user"
,呼叫$id
是"31"
。
在我當前用戶的數據庫中,用戶列的$note
值當前爲零(0
)。
因此,我認爲它會更新到31,但它保持在零。我錯誤地使用了pluck()
嗎?
謝謝。
乾杯,只是讓人們注意將來,關鍵是'first()'而不是'get()'。 –
ya,對不起 - 我意識到它並不那麼清楚,所以我在答案中添加了一些解釋... – IzzEps