madiluzi
madiluzi

Reputation: 129

Is there any way to not set updated_at column on Laravel

I'm trying to not set the updated_at column when i using update(), is there any way to make it possible? thank you

Upvotes: 0

Views: 303

Answers (2)

user1897253
user1897253

Reputation:

You can pass an array of options to the second parameter of the update method, which then tells laravel to not update the timestamps like so:

->update(['name' => 'foo'], ['timestamps' => false]);

Upvotes: 1

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26258

Check your table structure, I think updated_at is having TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, which means this column will automatically get its value when a new value added or some changes is done on a row. So remove that ON UPDATE CURRENT_TIMESTAMP and try again.

To check table definition try SHOW CREATE TABLE tablename.

Upvotes: 1

Related Questions