/** * Run the migration from the specified module. * * @param Module $module * * @return mixed */ protected function migrate(Module $module) { $path = str_replace(base_path(), '', (new Migrator($module))->getPath()); $this->call('migrate', ['--path' => $path, '--database' => $this->option('database'), '--pretend' => $this->option('pretend'), '--force' => $this->option('force')]); if ($this->option('seed')) { $this->call('module:seed', ['module' => $module->getName()]); } }
/** * @param Module $module * * @return void */ public function moduleSeed(Module $module) { $seeders = []; $name = $module->getName(); $config = $module->get('migration'); if (is_array($config) && array_key_exists('seeds', $config)) { foreach ((array) $config['seeds'] as $class) { if (@class_exists($class)) { $seeders[] = $class; } } } else { $class = $this->getSeederName($name); //legacy support if (@class_exists($class)) { $seeders[] = $class; } } if (count($seeders) > 0) { array_walk($seeders, [$this, 'dbSeed']); $this->info("Module [{$name}] seeded."); } }
/** @test */ public function it_gets_studly_name() { $this->assertEquals('Recipe', $this->module->getName()); }