Laravel在每个表上都有两个时间戳(created_at和updated_at)。 我认为它会在插入新行时插入created_at并在更新时更新updated_at。然而,当我更新模型时,created_at字段正在获得更新。
如何更改此行为或应使用哪种方法更新行并更新update_at时间戳?
现在我使用$model->save();
$point = Map::find($id);
$point->longitude = $request->longitude;
$point->latitude = $request->latitude;
$point->description = $request->description;
$point->save();
答案 0 :(得分:1)
我找到了解决问题的方法。 我手动创建了created_at和updated_at列,并且在update assign current_timestamp属性上创建了created_at。