Laravel DB Seeds - Test Data v Sample Data

后端 未结 1 1615
深忆病人
深忆病人 2021-01-03 03:56

I\'m probably misunderstanding exactly how this works, but what\'s the best way to accomplish this? I have something in mind but it seems quite hacky.

I have a set o

相关标签:
1条回答
  • 2021-01-03 04:37

    You could run a check on the current environment in your seeder file, and seed as needed

    <?php
    
    class DatabaseSeeder extends Seeder {
    
        public function run()
        {
                Eloquent::unguard();
    
                if (App::environment() === 'production')
                {
                    $this->call('ProductionSeeder');
                }
                else
                {
                    $this->call('StagingSeeder');
                }
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题