Laravel's seeder runs a variety of Model Events on my models which trigger New Order notification emails, among other things, from the Product::saved()
Model Event.
This significantly slows down database seeding. Is it possible to detect whether a Seed is being ran and if so, tell Laravel not to run the Model Events?
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 Dispatcher
Model::getEventDispatcher()
// Remove Dispatcher
Model::unsetEventDispatcher()
// Add Dispatcher
Model::setEventDispatcher(new \Illuminate\Events\Dispatcher);