Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Do not call the observer when there is a model update in laravel

//Additionally, updating events are only fired when you update your
//model directly.
//That means this will fire an event:
$user = User::findOrFail($id);
$user->update($data);
//While something like this will not

User::where('id', $id)->update($data);
//or 
ProductModel::query()->where('id', $product->id)
  ->update(['viewed' => $product->viewed + 1]);
 
PREVIOUS NEXT
Tagged: #Do #call #observer #model #update #laravel
ADD COMMENT
Topic
Name
7+8 =