/** * @return mixed */ public function seedAdminRole() { if ($this->command->option('verbose')) { return $this->command->call('db:seed', ['--class' => 'Modules\\User\\Database\\Seeders\\GroupSeedTableSeeder']); } return $this->command->callSilent('db:seed', ['--class' => 'Modules\\User\\Database\\Seeders\\GroupSeedTableSeeder']); }
/** * @param Command $console * @return bool */ protected function generate(Command $console) { $this->generateFolders(); $this->generateFiles(); $console->call('module:seed-make', array('module' => $this->name, 'name' => $this->Name, '--master')); $console->call('module:controller', array('module' => $this->name, 'controller' => $this->Name . 'Controller')); $console->info("Module [{$this->Name}] has been created successfully."); return true; }
/** * Fire the install script. * * @param Command $command * * @return mixed */ public function fire(Command $command) { if ($command->option('verbose')) { $command->call('key:generate'); $command->call('api:key-generate'); return; } $command->callSilent('key:generate'); $command->callSilent('api:key-generate'); }
public function call($command, array $arguments = [], array $options = []) { foreach ($options as $option => $value) { $arguments['--' . $option] = $value; } return parent::call($command, $arguments); }
/** * Generate some resources. */ public function generateResources() { $this->console->call('module:make-seed', ['name' => $this->getName(), 'module' => $this->getName(), '--master' => true]); $this->console->call('module:make-provider', ['name' => $this->getName() . 'ServiceProvider', 'module' => $this->getName(), '--master' => true]); $this->console->call('module:make-controller', ['controller' => $this->getName() . 'Controller', 'module' => $this->getName()]); $this->console->call('module:make-backend-controller', ['controller' => $this->getName() . 'Controller', 'module' => $this->getName()]); }
/** * Generate request classes. */ public function generateLangResources() { if (!$this->confirm('Do you want to create the language resource files?')) { return; } foreach ($this->getMainTables() as $table) { $this->console->call('generate:lang', ['name' => $this->getEntity($table), '--languages' => $this->console->option('languages'), '--translations' => $this->getLangTranslations($table), '--force' => $this->console->option('force')]); } }
/** * Generate request classes. */ public function generateRequest() { if (!$this->confirm('Do you want to create form request classes?')) { return; } foreach (['Create', 'Update'] as $request) { $name = $this->getPrefix('/') . $this->getEntities() . '/' . $request . Str::studly($this->getEntity()) . 'Request'; $this->console->call('generate:request', ['name' => $name, '--scaffold' => true, '--auth' => true, '--rules' => $this->console->option('fields'), '--force' => $this->console->option('force')]); } }
/** * Handle the command. * * @param AddonCollection $addons */ public function handle(AddonCollection $addons) { foreach ($this->paths as $path) { $options = ['--path' => $path]; if ($this->command->option('force')) { $options['--force'] = true; } if ($this->command->option('pretend')) { $options['--pretend'] = true; } if ($this->command->option('seed')) { $options['--seed'] = true; } if ($database = $this->command->option('database')) { $options['--database'] = $database; } $this->command->call('migrate', $options); } return; }
/** * Handle the command. * * @param AddonCollection $addons */ public function handle(AddonCollection $addons) { foreach ($addons->enabled() as $addon) { $options = ['--addon' => $addon->getNamespace()]; if ($this->command->option('force')) { $options['--force'] = true; } if ($this->command->option('pretend')) { $options['--pretend'] = true; } if ($this->command->option('seed')) { $options['--seed'] = true; } if ($database = $this->command->option('database')) { $options['--database'] = $database; } $this->command->call('migrate', $options); } return; }
/** * Fire the install script. * * @param Command $command * * @return mixed */ public function fire(Command $command) { if ($command->option('verbose')) { $command->blockMessage('Themes', 'Publishing theme assets ...', 'comment'); } if ($command->option('verbose')) { $command->call('stylist:publish'); return; } $command->callSilent('stylist:publish'); }
/** * Fire the install script * @param Command $command * @return mixed */ public function fire(Command $command) { $this->command = $command; // Publish asgard configs if ($this->command->option('verbose')) { $this->command->call('vendor:publish', ['--provider' => 'Modules\\Core\\Providers\\CoreServiceProvider']); } else { $this->command->callSilent('vendor:publish', ['--provider' => 'Modules\\Core\\Providers\\CoreServiceProvider']); } if (!$this->checkIsInstalled()) { return $this->command->error('No user driver was installed. Please check the presence of a Service Provider'); } $this->publish(); $this->configure(); $this->migrate(); $this->seed(); $this->createFirstUser(); if ($this->command->option('verbose')) { $command->info($this->driver . ' succesfully configured'); } }
/** * Fire the install script * @param Command $command * @return mixed */ public function fire(Command $command) { if ($command->option('verbose')) { $command->blockMessage('Seeds', 'Running the module seeds ...', 'comment'); } foreach ($this->modules as $module) { if ($command->option('verbose')) { $command->call('module:seed', ['module' => $module]); continue; } $command->callSilent('module:seed', ['module' => $module]); } }
/** * Fire the install script * @param Command $command * @return mixed */ public function fire(Command $command) { if ($command->option('verbose')) { $command->blockMessage('Module assets', 'Publishing module assets ...', 'comment'); } foreach ($this->modules as $module) { if ($command->option('verbose')) { $command->call('module:publish', ['module' => $module]); continue; } $command->callSilent('module:publish', ['module' => $module]); } }
/** * Fire the install script * @param Command $command * @return mixed */ public function fire(Command $command) { if ($command->option('verbose')) { $command->blockMessage('Migrations', 'Starting the module migrations ...', 'comment'); } foreach ($this->modules as $module) { if ($command->option('verbose')) { $command->call('module:migrate', ['module' => $module]); continue; } $command->callSilent('module:migrate', ['module' => $module]); } }
/** * Fire demo scripts. * * @param Command $command * * @return bool */ public function enable(Command $command) { $command->call('down'); foreach ($this->scripts as $script) { try { $this->app->make($script)->fire($command); } catch (\Exception $e) { $command->error($e->getMessage()); return false; } } $command->call('up'); return true; }
/** * Clear the settings cache, and backup the databases. * * @param \Illuminate\Console\Command $command * * @return void */ public function fire(Command $command) { $command->line('Clearing settings cache...'); $this->cache->clear(); $command->line('Settings cache cleared!'); $command->line('Backing up database...'); try { $command->call('db:backup', ['--compression' => 'gzip', '--database' => $this->config->get('database.default'), '--destination' => 'local', '--destinationPath' => Carbon::now()->format('Y-m-d H.i.s'), '--no-interaction' => true]); } catch (Exception $e) { $command->error($e->getMessage()); $command->line('Backup skipped!'); } $command->line('Backup completed!'); }
/** * Executa rollback das migrations do modulo * * @param array $rollback * @param Command $command * @return array|bool */ private static function runMigrationRollback(array $rollback, Command $command) { $errors = []; if (array_key_exists(Strings::ROLLBACK_MIGRATE, $rollback)) { if ($rollback[Strings::ROLLBACK_MIGRATE] == true) { try { $command->call(Strings::COMMAND_ROLLBACK); if (array_key_exists(Strings::ROLLBACK_LOADED_MODULE_TAG, $rollback)) { if (count(DB::table(Strings::TABLE_PROJECT_MODULES)->where(Strings::TABLE_PROJECT_MODULES_NAME, $rollback[Strings::ROLLBACK_LOADED_MODULE_TAG])->first()) > 0) { $errors[] = Strings::ERROR_MIGRATE_ROLLBACK; } } else { $errors[] = Strings::ERROR_GET_MODULE_NAME_FROM_DB; } } catch (Exception $e) { $errors[] = Strings::ERROR_DATABASE_CONECTION; } } } return !empty($errors) ? $errors : true; }
/** * Prompt user to run the migrations */ private function runMigrations() { if (!$this->fromFile) { $editMigrations = $this->command->confirm('Would you like to edit your migrations file before running it [y/n]? ', true); if ($editMigrations) { $this->command->info('Remember to run "php artisan migrate" after editing your migration file'); $this->command->info('And "php artisan db:seed" after editing your seed file'); } else { while (true) { try { $this->command->call('migrate'); $this->command->call('db:seed'); break; } catch (\Exception $e) { $this->command->info('Error: ' . $e->getMessage()); $this->command->error('This table already exists and/or you have duplicate migration files.'); $this->command->confirm('Fix the error and enter "yes" ', true); } } } } }
/** * Handle a command.updatecache event. * * @param \Illuminate\Console\Command $command * * @return void */ public function onUpdateCache(Command $command) { $command->line('Clearing cache...'); $command->call('cache:clear'); $command->info('Cache cleared!'); }
/** * Generate some resources. */ public function generateResources() { $this->console->call('plugin:make-provider', ['name' => $this->getName() . 'ServiceProvider', 'plugin' => $this->getName(), '--master' => true]); $this->console->call('plugin:make-controller', ['controller' => $this->getName() . 'Controller', 'plugin' => $this->getName()]); }
/** * Constroi as rotas dos modulos * * @param string $moduleType * @param string $moduleName * @param array $rollback * @param Command $command * @return array|bool */ public static function runMigrations($moduleType, $moduleName, array &$rollback, Command $command) { try { $errors = []; //Roda dump autoload shell_exec(Strings::COMMAND_DUMP_AUTOLOAD); //Tenta Rodar a migration $command->call(Strings::COMMAND_MIGRATE); //Seta a flag de migrations para true no rollback $rollback[Strings::ROLLBACK_MIGRATE] = Strings::TRUE_STRING; /////VERIFICAR SE MIGRATE RODOU DE FORMA ADEQUADA////// if (!(count(DB::table(Strings::TABLE_PROJECT_MODULES)->where(Strings::TABLE_PROJECT_MODULES_NAME, $moduleType . Strings::MODULE_TYPE_NAME_SEPARATOR . $moduleName)->first()) > 0)) { $errors[] = Strings::ERROR_MIGRATE; } /////////////////////////////////////////////////////// } catch (\Exception $e) { $errors[] = Strings::migrationException($e->getMessage()); } return !empty($errors) ? $errors : true; }
/** * Optimize the framework for better performance. * * @return void */ protected function optimize(Command $console) { $console->call('optimize'); }