问题描述
对于传统表格报告
,一些现有的列 created_at
和 updated_at
命名为 date_created
和 date_modified
我想告诉我有口皆碑的报告
自定义时间戳列名称。
该文档仅提供关闭时间戳或提供自定义时间戳格式的参考。
在模型中,您可以定义这样的常量来更改列名称
class BaseModel扩展Eloquent {
const CREATED_AT ='date_created';
const UPDATED_AT ='date_modified';
}
或使用你可以使用这样的东西
I am migrating a site from codeigniter to Laravel.
For a legacy table reports
, some existing columns created_at
and updated_at
are named date_created
and date_modified
respectively.
I wish to tell my eloquent Report
model about these custom timestamp column names.
The documentation only provide reference to turning timestamps off or providing custom timestamp formats.
http://laravel.com/docs/eloquent#timestamps
In model your can define constants like this to change the column names
class BaseModel extends Eloquent {
const CREATED_AT = 'date_created';
const UPDATED_AT = 'date_modified';
}
or use you can use something like this Managing Timestamps
这篇关于Laravel - 自定义时间戳列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!