Exemplo n.º 1
0
 /**
  * Run migrations for the specified module.
  *
  * @param string $slug
  *
  * @return mixed
  */
 protected function migrate($slug)
 {
     if ($this->module->exists($slug)) {
         $module = $this->module->where('slug', $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);
         event($slug . '.module.migrated', [$module, $this->option()]);
         // 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.');
     }
 }
 /**
  * Run the migration rollback for the specified module.
  *
  * @param string $slug
  *
  * @return mixed
  */
 protected function rollback($slug)
 {
     $module = $this->module->where('slug', $slug);
     $this->requireMigrations($slug);
     $this->call('migrate:rollback', ['--database' => $this->option('database'), '--force' => $this->option('force'), '--pretend' => $this->option('pretend')]);
     event($slug . '.module.rolledback', [$module, $this->option()]);
 }
 /**
  * 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 {
         return $this->migrate();
     }
 }
Exemplo n.º 4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $slug = $this->parseSlug($this->argument('slug'));
     $name = $this->parseName($this->argument('name'));
     if ($this->module->exists($slug)) {
         $this->modulePath = $this->module->getPath();
         $this->moduleInfo = collect($this->module->where('slug', $slug)->first());
         $this->container['slug'] = $slug;
         $this->container['name'] = $name;
         return $this->generate();
     }
     return $this->error('Module ' . $this->container['slug'] . ' does not exist.');
 }
Exemplo n.º 5
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);
     }
 }
Exemplo n.º 6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $slug = $this->parseSlug($this->argument('slug'));
     $name = $this->parseName($this->argument('name'));
     if ($this->module->exists($slug)) {
         $module = $this->module->where('slug', $slug);
         $this->modulePath = $this->module->getPath();
         $this->moduleInfo = collect($module);
         $this->container['slug'] = $slug;
         $this->container['name'] = $name;
         return $this->generate();
         event($slug . '.module.made.' . strtolower($this->type), [$module, $this->option()]);
     }
     return $this->error('Module ' . $this->container['slug'] . ' does not exist.');
 }
Exemplo n.º 7
0
 /**
  * Run the migration reset for the specified module.
  *
  * Migrations should be reset in the reverse order that they were
  * migrated up as. This ensures the database is properly reversed
  * without conflict.
  *
  * @param string $slug
  *
  * @return mixed
  */
 protected function reset($slug)
 {
     $this->migrator->setconnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     $migrationPath = $this->getMigrationPath($slug);
     $migrations = array_reverse($this->migrator->getMigrationFiles($migrationPath));
     if (count($migrations) == 0) {
         return $this->error('Nothing to rollback.');
     }
     foreach ($migrations as $migration) {
         $module = $this->module->where('slug', $slug);
         $this->info('Migration: ' . $migration);
         $this->runDown($slug, $migration, $pretend);
         event($slug . '.module.reset', [$module, $this->option()]);
     }
 }
Exemplo n.º 8
0
 /**
  * Generate the module.
  */
 protected function generate()
 {
     $steps = ['Generating folders...' => 'generateFolders', 'Generating .gitkeep...' => 'generateGitkeep', 'Generating files...' => 'generateFiles', 'Optimizing module cache...' => 'optimizeModules'];
     $progress = new ProgressBar($this->output, count($steps));
     $progress->start();
     foreach ($steps as $message => $function) {
         $progress->setMessage($message);
         $this->{$function}();
         $progress->advance();
     }
     $progress->finish();
     $slug = $this->container['slug'];
     $module = $this->module->where('slug', $slug);
     event($slug . '.module.made');
     $this->info("\nModule generated successfully.");
 }