Is it possible to prevent Laravel running Model Events when the database is being Seeded?
There are functions on the Model
class which will allow you to ignore events.
Before using a model to seed, you will need to do something like this...
YourModel::flushEventListeners();
I recommend to remove the Dispatcher in this Case from the Eloquent Model.
For example.
// Check DispatcherModel::getEventDispatcher()// Remove DispatcherModel::unsetEventDispatcher()// Add DispatcherModel::setEventDispatcher(new \Illuminate\Events\Dispatcher);