Advertisement
nejtr0n

laravel skip events on update

May 2nd, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. protected static function boot()
  2. {
  3. parent::boot();
  4.  
  5. static::saved(function(Discount $discount) {
  6. $condition_name = "";
  7. foreach ($discount->conditions as $condition) {
  8. $condition_name .= $condition["name"]. ' ';
  9. }
  10. $dispatcher = static::$dispatcher;
  11. static::unsetEventDispatcher();
  12. $discount->update(['condition' => trim($condition_name)]);
  13. static::setEventDispatcher($dispatcher);
  14. });
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement