Sunday, March 19, 2017

laravel deactivate event for update() on model

When a model of me is updated an event is triggered:

protected $events = [
    'updated' => ZoneUpdated::class,
];

The event listener which is triggered will create on the model too:

public function handle(ZoneUpdated $event)
{
    Zone::find($event->zone->id)->update([
        'updated' => true,
        'valid'   => 'u',
    ]);
}

How can I disable the listener to fire a new event, because at the moment this produces an infinite loop.



via wichtel

Advertisement