Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent
Last updated 2 years ago.
0
Solution

Its not a bug ... you are not updating a model there. That is an update statement being applied via a direct query. That is Eloquent\Builder@update not Model@update. That could be updating many records.

If you want to update a model directly, get the model then call update on it.

Last updated 8 years ago.
0

Thank you for your response lagbox! I understand what you are saying, but I invoked the update statement via Foo, so I feel like the model events should fire. If I invoked via db::update, I would understand why they wouldn't be. I want the efficiency of the batch update with the features of the model update.

0

It does not know what 'records' it is updating as its a DB update statement. It would have to do a select based on the query, then get all the ids then do the update.

You could simulate this potentially with your own method.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

andycat andycat Joined 9 Jun 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.