ConfigsTableSeeder.php 590 B

1234567891011121314151617181920212223242526
  1. <?php
  2. use App\Models\ConfigCategory;
  3. use App\Models\Config;
  4. use Illuminate\Database\Seeder;
  5. class ConfigsTableSeeder extends Seeder
  6. {
  7. /**
  8. * Run the database seeds.
  9. *
  10. * @return void
  11. */
  12. public function run()
  13. {
  14. $cates = ConfigCategory::all();
  15. if (empty($cates)) {
  16. $this->call(ConfigCategoriesTableSeeder::class);
  17. $cates = ConfigCategory::all();
  18. }
  19. $cates->each(function (ConfigCategory $cate) {
  20. $cate->configs()->createMany(factory(Config::class, 2)->make()->toArray());
  21. });
  22. }
  23. }