Change name of Laravel's created_at and updated_at
The accepted answer may cause problems with updating timestamps unfortunately.
You'd better override consts on your model:
const CREATED_AT = 'post_date';
const UPDATED_AT = 'post_modified';
then methods getCreatedAtColumn
and getUpdatedAtColumn
will return post_date
and post_modified
respectively, but won't do any harm.
For the other columns you need use events like @Oni suggested.
If you look into the source of the Eloquent
class
https://github.com/illuminate/database/blob/4.2/Eloquent/Model.php#L223-L235
You should be able to change these column names pretty easily by overriding those constants.
<?php
class YourModel extends Eloquent {
/**
* The name of the "created at" column.
*
* @var string
*/
const CREATED_AT = 'post_date';
/**
* The name of the "updated at" column.
*
* @var string
*/
const UPDATED_AT = 'post_modified';
}
As for the _gmt
version of those timestamps, you might want to look into events
. Here is a good start
http://driesvints.com/blog/using-laravel-4-model-events