/**
  * 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()]);
 }
 /**
  * Get all modules.
  *
  * @return array
  */
 protected function getModules()
 {
     $modules = $this->module->all();
     $results = [];
     foreach ($modules as $module) {
         $results[] = $this->getModuleInformation($module);
     }
     return array_filter($results);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return null;
     }
     $module = $this->argument('module');
     if ($module) {
         return $this->rollback($module);
     } else {
         foreach ($this->module->all() as $module) {
             $this->rollback($module['slug']);
         }
     }
 }
Beispiel #4
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);
     }
 }
 /**
  * Get all of the migration paths.
  *
  * @return array
  */
 protected function getMigrationPaths()
 {
     $slug = $this->argument('slug');
     $paths = [];
     if ($slug) {
         $paths[] = module_path($slug, 'Database/Migrations');
     } else {
         foreach ($this->module->all() as $module) {
             $paths[] = module_path($module['slug'], 'Database/Migrations');
         }
     }
     return $paths;
 }
Beispiel #6
0
 /**
  * Seed the specific module.
  *
  * @param  string $module
  * @return array
  */
 protected function seed($module)
 {
     $params = array();
     $moduleName = studly_case($module);
     $namespace = $this->module->getNamespace();
     $rootSeeder = $moduleName . 'DatabaseSeeder';
     $fullPath = $namespace . $moduleName . '\\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);
     }
 }
 /**
  * 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()]);
     }
 }
Beispiel #8
0
 /**
  * Returns module manifest information.
  *
  * @param string  $module
  * @return array
  */
 protected function getModuleInformation($module)
 {
     return ['#' => $module['order'], 'name' => $module['name'], 'slug' => $module['slug'], 'description' => $module['description'], 'status' => $this->module->isEnabled($module['slug']) ? 'Enabled' : 'Disabled'];
 }
Beispiel #9
0
 /**
  * Get the configured module base namespace.
  *
  * @return string
  */
 protected function getBaseNamespace()
 {
     return $this->module->getNamespace();
 }
 /**
  * Get migration directory path.
  *
  * @param  string $slug
  * @return string
  */
 protected function getMigrationPath($slug)
 {
     $path = $this->module->getModulePath($slug);
     return $path . 'Database/Migrations/';
 }
 /**
  * Replace placeholder text with correct values.
  *
  * @param  string $content
  * @return string
  */
 protected function formatContent($content)
 {
     return str_replace(['{{className}}', '{{moduleName}}', '{{namespace}}'], [$this->className, $this->moduleName, $this->module->getNamespace()], $content);
 }
 /**
  * Get module migration path.
  *
  * @return string
  */
 protected function getPath()
 {
     $path = $this->module->getModulePath($this->moduleName);
     return $path . 'Database/Migrations/';
 }
Beispiel #13
0
 /**
  * Replace placeholder text with correct values.
  *
  * @return string
  */
 protected function formatContent($content)
 {
     return str_replace(['{{slug}}', '{{name}}', '{{namespace}}', '{{version}}', '{{description}}', '{{author}}', '{{path}}'], [$this->container['slug'], $this->container['name'], $this->container['namespace'], $this->container['version'], $this->container['description'], $this->container['author'], $this->module->getNamespace()], $content);
 }