My model class is User and observer class is UserObserver.
I have added some code in the updated method of UserObserver that will run everytime the User model update function is used.
When I debug I can understand that User::find(2) return User model object and User::where('id', 2) will return a Builder
The code in the UserObserver works when User data update like shown below: User::find(2)->update(['name'=>'Update Name']); However, the code in the UserObserver won't run when User data is updated in the following way: User::where('id', 2)->update(['name'=>'Update Name']);
So, how can I make use of our observer class method regardless of whether it is updated using User Model object or Builder object?