/**
  * Run migrations for the specified module.
  *
  * @param string $slug
  *
  * @return mixed
  */
 protected function migrate($slug = null)
 {
     $pretend = Arr::get($this->option(), 'pretend', false);
     if (!is_null($slug) && $this->module->exists($slug)) {
         $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 {
         $modules = $this->module->all();
         if (count($modules) == 0) {
             return $this->error("Your application doesn't have any modules.");
         }
         $migrationsAll = [];
         foreach ($modules as $module) {
             $path = $this->getMigrationPath($module['slug']);
             $files = $this->migrator->getMigrationFiles($path);
             $ran = $this->migrator->getRepository()->getRan();
             $migrations = array_diff($files, $ran);
             $this->migrator->requireFiles($path, $migrations);
             $migrationsAll = array_merge($migrationsAll, $migrations);
         }
         if (floatval(App::version()) > 5.1) {
             $pretend = ['pretend' => $pretend];
         }
         sort($migrationsAll);
         $this->migrator->runMigrationList($migrationsAll, $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')) {
             foreach ($modules as $module) {
                 $this->call('module:seed', ['module' => $module['slug'], '--force' => true]);
             }
         }
     }
 }
 /**
  * Run migrations for the specified module.
  *
  * @param  string $slug
  * @return mixed
  */
 protected function migrate($slug)
 {
     $moduleName = Str::studly($slug);
     if ($this->module->exists($slug)) {
         $pretend = $this->option('pretend');
         $path = $this->getMigrationPath($slug);
         $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->output->writeln($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 [{$moduleName}] does not exist.");
     }
 }
示例#3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $module = $this->argument('module');
     $moduleName = studly_case($module);
     if (isset($module)) {
         if (!$this->module->exists($module)) {
             return $this->error("Module [{$moduleName}] does not exist.");
         }
         if ($this->module->isEnabled($module)) {
             $this->seed($module);
         } elseif ($this->option('force')) {
             $this->seed($module);
         }
         return;
     } else {
         if ($this->option('force')) {
             $modules = $this->module->all();
         } else {
             $modules = $this->module->enabled();
         }
         foreach ($modules as $module) {
             $this->seed($module['slug']);
         }
     }
 }
示例#4
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.');
     }
 }
 /**
  * Fire off the handler.
  *
  * @param  \Illuminate\Console\Command $console
  * @param  string                      $slug
  * @param  string                      $class
  * @return bool
  */
 public function fire(Command $console, $slug, $class)
 {
     $this->console = $console;
     $this->moduleName = Str::studly($slug);
     $this->className = studly_case($class);
     if ($this->module->exists($this->moduleName)) {
         $this->makeFile();
         return $this->console->info("Created Module Form Request: [{$this->moduleName}] " . $this->getFilename());
     }
     return $this->console->info("Module [{$this->moduleName}] does not exist.");
 }
示例#6
0
 /**
  * Fire off the handler.
  *
  * @param  \Caffeinated\Modules\Console\ModuleMakeCommand $console
  * @param  string                                         $slug
  * @return bool
  */
 public function fire(Command $console, $slug)
 {
     $this->console = $console;
     $this->slug = strtolower($slug);
     $this->name = Str::studly($slug);
     if ($this->module->exists($this->slug)) {
         $console->comment('Module [{$this->name}] already exists.');
         return false;
     }
     $this->generate($console);
 }
 /**
  * Fire off the handler.
  *
  * @param  \Caffeinated\Modules\Console\ModuleMakeMigrationCommand $console
  * @param  string                                                  $slug
  * @return string
  */
 public function fire(Command $console, $slug, $table)
 {
     $this->console = $console;
     $this->moduleName = Str::studly($slug);
     $this->table = strtolower($table);
     $this->migrationName = snake_case($this->table);
     $this->className = studly_case($this->migrationName);
     if ($this->module->exists($slug)) {
         $this->makeFile();
         $this->console->info("Created Module Migration: [{$this->moduleName}] " . $this->getFilename());
         return exec('composer dump-autoload');
     }
     return $this->console->info("Module [{$this->moduleName}] does not exist.");
 }
示例#8
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.');
 }
示例#9
0
 /**
  * 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']);
         }
     }
 }
示例#10
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.');
 }