Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - custom timestamp column names

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

like image 896
Gravy Avatar asked Jul 29 '14 07:07

Gravy


1 Answers

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

like image 60
Arun Kumar Avatar answered Nov 17 '22 06:11

Arun Kumar