Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ssquare's avatar

Laravel create method inserting timestamp to updated_at column as well

I am trying to insert data with something simple like

$data_arr['created_by'] = $this->data['user_id'];
$data_table = Model::create($data_arr);

But it is updating both created_at and updated_at table at once. I don't want to fill updated_at column at the time of creation.

How can I get rid of this?

0 likes
2 replies
Vilfago's avatar
Vilfago
Best Answer
Level 20

It's the default behaviour... you can do it manually in adding public $timestamps = false; in your model, and manually handle timestamp.

IMO, I go this way, and query when created_at is different from updated_at to have the real updated lines.

Snapey's avatar

Seems perfectly reasonable that last updated was when the record was created. But I guess (for now) you have your reasons

You can prevent automatic setting of the timestamps by setting $timestamps to false in your model, either permanently or just before this create call.

Please or to participate in this conversation.