michaelnguyen547's avatar

update some attributes and do not fire saving events

I have a model observers for saving event on estimated_fee. I only want the saving event when i am saving estimated_fee. If I update other attributes, I dont want the saving event fired. $model->save() always fire the saving event.

Is there other way?

0 likes
1 reply
Tangente's avatar
Tangente
Best Answer
Level 9

I may be wrong, but I think those model events will always fire, like saving, creating, etc . You can’t stop them from firing, but you can decide on how you listen to them and handle them though. I suggest you add the logic in the handler method, like

Public function saving(Product $product) { If( $product->estimated_fee ) { //do your code here }

Please or to participate in this conversation.