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

keevitaja's avatar

Eloquent updated event do not fire on update

Hi,

I'm not sure, perhaps this is expected behavior, but the following occurs:

If i update a model with Model::find(1)->update(['title' => 'old title']); updated event is fired only in case the title was actually changed. Meaning if it was 'old title' before, then event is not fired.

Is there a way to force this event to be fired each time i do update()?

Edit:

I can use saved event. That fill fire even if record was not changed... Still i think it will fire in case of the creation, which i do not need!

And yes. As i have created event as well, it will first create new record and then update it. Is there a way to fix this?

0 likes
2 replies
Cocoon's avatar
Cocoon
Best Answer
Level 7

Maybe you could add a ->touch(), which should at least update the updated_at timestamp and therefore trigger the updated event? Or even include this field it in the array of the update function?

3 likes
keevitaja's avatar

Yeah, well there is nothing wrong with the elequent updated event, as Model::find(1)->update(['title' => 'old title']); does not update anything if title is not changed. Still update() returns true.

Using touch() would end up with unwanted DB query, in case record was updated.

Anyways it is a strange issue with saved event working.

@Cocoon adding updated_at property does fix it!

1 like

Please or to participate in this conversation.