Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change column names used to save timestamp

When storing or editing data in a table by laravel it creates a timestamp that uses the fields created_at and updated_at.

But I have to store the data in a table shared with another system, and it uses another nomenclature to store this data.

Without being the solution to set the timestamp = false and at the time of storing myself add the timestamp there.

In the model itself do I have to set the cr‍‍‍‍‍‍‍eated_a‌‌‌‌‌‌t and updated_at data to be saved in other columns?‍‍‍‍‍‌‌‌‌‌

like image 229
Magas Avatar asked Nov 25 '25 22:11

Magas


1 Answers

As Eloquent documentation says, you can override consts on your models

const CREATED_AT = 'created_at_column_name';
const UPDATED_AT = 'updated_at_column_name'; 
like image 158
Andriy Sushchyk Avatar answered Nov 27 '25 12:11

Andriy Sushchyk