Laravel: Reactivating listeners after flushEventListeners()
Laravel: Reactivating listeners after flushEventListeners()
I have some functionality that is being enacted by my model's event handler that I need to prevent from firing under a specific circumstance.
protected static function bootLogSubject()
{
static::created(function ($subject) {
$subject->logContent('create', Auth::user());
});
I am aware that I can use flushEventListeners()
to stop the event firing. This works fine, but is it possible to switch the listeners back on again (unflush? bind?) once I have finished what I need to do?
flushEventListeners()
1 Answer
1
This seems to work:
Model::boot();
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment