예제 #1
0
 /**
  * Seed the specific module.
  *
  * @param  string $module
  * @return array
  */
 protected function seed($slug)
 {
     $module = $this->module->where('slug', $slug)->first();
     $params = [];
     $namespacePath = $this->module->getNamespace();
     $rootSeeder = $module['namespace'] . 'DatabaseSeeder';
     $fullPath = $namespacePath . '\\' . $module['namespace'] . '\\Database\\Seeds\\' . $rootSeeder;
     if (class_exists($fullPath)) {
         if ($this->option('class')) {
             $params['--class'] = $this->option('class');
         } else {
             $params['--class'] = $fullPath;
         }
         if ($option = $this->option('database')) {
             $params['--database'] = $option;
         }
         if ($option = $this->option('force')) {
             $params['--force'] = $option;
         }
         $this->call('db:seed', $params);
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->prepareDatabase();
     if (!empty($this->argument('slug'))) {
         $module = $this->module->where('slug', $this->argument('slug'))->first();
         if ($this->module->isEnabled($module['slug'])) {
             return $this->migrate($module['slug']);
         } elseif ($this->option('force')) {
             return $this->migrate($module['slug']);
         } else {
             return $this->error('Nothing to migrate.');
         }
     } else {
         if ($this->option('force')) {
             $modules = $this->module->all();
         } else {
             $modules = $this->module->enabled();
         }
         foreach ($modules as $module) {
             $this->migrate($module['slug']);
         }
     }
 }