在我的插件中,当我编辑和保存项目时,某些字段值不会刷新。例如,即使已在数据库中对其进行更新,“ updated_at”字段仍显示旧的DateTime值。如何刷新特定的字段值?我应该使用局部还是有另一种方法?
嗯,您需要将模型的certain attributes/variables
设置为achieve
。
class YourModel extends Model
{
// set this to true
public $timestamps = true;
}
$ timestamps:如果
true
将automatically
设置created_at和updated_at字段。 (确保您的表具有相同的确切列名created_at和updated_at)
检查参考:https://octobercms.com/docs/database/model#standard-properties
如有任何疑问,请发表评论。