Change name of Laravel's created_at and updated_at

前端 未结 4 1176
眼角桃花
眼角桃花 2020-12-02 14:09

Can I map Laravel\'s timestamps from:

created_at to post_date and post_date_gmt?

updated_at to post

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 15:00

    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.

    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

提交回复
热议问题