/** * Run migrations for the specified module. * * @param string $slug * @return mixed */ protected function migrate($slug) { if ($this->module->exists($slug)) { $pretend = Arr::get($this->option(), 'pretend', false); $path = $this->getMigrationPath($slug); if (floatval(App::version()) > 5.1) { $pretend = ['pretend' => $pretend]; } $this->migrator->run($path, $pretend); // Once the migrator has run we will grab the note output and send it out to // the console screen, since the migrator itself functions without having // any instances of the OutputInterface contract passed into the class. foreach ($this->migrator->getNotes() as $note) { if (!$this->option('quiet')) { $this->line($note); } } // Finally, if the "seed" option has been given, we will re-run the database // seed task to re-populate the database, which is convenient when adding // a migration and a seed at the same time, as it is only this command. if ($this->option('seed')) { $this->call('module:seed', ['module' => $slug, '--force' => true]); } } else { return $this->error("Module does not exist."); } }
/** * Execute the console command. * * @return mixed */ public function fire() { $slug = $this->argument('slug'); if (isset($slug)) { if (!$this->module->exists($slug)) { return $this->error("Module does not exist."); } if ($this->module->isEnabled($slug)) { $this->seed($slug); } elseif ($this->option('force')) { $this->seed($slug); } return; } else { if ($this->option('force')) { $modules = $this->module->all(); } else { $modules = $this->module->enabled(); } foreach ($modules as $module) { $this->seed($module['slug']); } } }