Answers for "boot model laravel seeder"

PHP
0

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 */
}
Posted by: Guest on August-04-2021

Code answers related to "boot model laravel seeder"

Browse Popular Code Answers by Language