boot model laravel seeder
static::creating(function ($model) {
if (!Seeder::isRunning()) {
// do something only when the seeder is not running
}
})
// Add helper into your project
class Seeder
{
protected static $running = false;
public function isRunning()
{
return static::$running;
}
public function start()
{
static::$running = true;
}
}
// and than in your DatabaseSeeder class:
public function run()
{
Seeder::start();
/* your seeder coder */
}