/** * Get module * * @throws ModuleNotFoundException * * @return Module */ protected function getModule() { /** @var Command $this */ $module = $this->argument('module') ?: workbench()->getUsedNow(); /** @var string $module */ return workbench()->findOrFail($module); }
/** * Dump module * * @param string $module */ private function dump($module) { $module = workbench()->findOrFail($module); $this->line("<comment>Running for module</comment>: {$module}"); chdir($module->getPath()); passthru('composer dump -o -n -q'); }
/** * Run the migration from the specified module. * * @param string $name */ private function migrate($name) { $module = workbench()->findOrFail($name); $this->call('migrate', ['--path' => $this->getPath($module), '--database' => $this->getStringOption('db'), '--pretend' => $this->getBoolOption('pretend'), '--force' => $this->getBoolOption('force')]); if ($this->getBoolOption('seed')) { $this->call('module:seed', ['module' => $name]); } }
/** * Execute the console command. * * @return mixed */ public function handle() { foreach ($this->getNames() as $name) { (new ModuleGenerator($name))->setFilesystem(app('files'))->setWorkbench(workbench())->setConfig(config())->setConsole($this)->setForce($this->getBoolOption('force'))->setPlain($this->getBoolOption('plain'))->generate(); } $this->line('<comment>Dump all modules autoload</comment>'); chdir(base_path()); passthru('composer dump -o -n -q'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $module = str_studly($this->getStringArg('module')); if (!workbench()->has($module)) { workbench()->setUsed($module); $this->info("Module [{$module}] used successfully."); } else { $this->error("Module [{$module}] does not exists."); } }
/** * Rollback migration from the specified module. * * @param Module|string $module */ private function reset($module) { if (is_string($module)) { $module = workbench()->findOrFail($module); } $this->line('Running for module: <info>' . $module->getName() . '</info>'); $migrated = (new Migrator($module))->reset(); if (count($migrated)) { foreach ($migrated as $migration) { $this->line("Rollback: <info>{$migration}</info>"); } } else { $this->comment('Nothing to rollback.'); } }
/** * Get modules. * * @return array */ private function getModules() { $workbench = workbench(); if (!$this->option('only')) { return workbench()->all(); } $choice = $this->anticipate('Select only modules that are ?', ['enabled', 'disabled', 'ordered']); switch ($choice) { case 'enabled': return $workbench->getByStatus(1); // no break // no break case 'disabled': return $workbench->getByStatus(0); // no break // no break case 'ordered': default: return $workbench->getOrdered($this->getStringOption('dir')); // no break } }
/** * Generate the assets folder. */ private function makeAssetsFolder() { $this->generateDirectory(workbench()->config('paths.assets'), 'Assets directory created successfully', 'Assets directory already exist'); }
/** * Get the destination file path. * * @param string $name * * @throws InvalidFileNameException * * @return string */ protected function getDestinationFilePath($name = '') { $modulePath = workbench()->getModulePath($this->getModuleName()); $filePath = workbench()->config('paths.generator.' . $name, ''); return $modulePath . $filePath . '/' . $this->getFileName() . '.php'; }
/** * Get template contents. * * @return string */ protected function getTemplateContents() { $module = $this->getModule(); return Stub::create('/request.stub', ['MODULE' => $module->getStudlyName(), 'NAME' => $this->getFileName(), 'MODULE_NAMESPACE' => workbench()->config('namespace'), 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass()])->render(); }
/** * Execute the console command. * * @return mixed */ public function handle() { workbench()->update($name = $this->getModuleName()); $this->info("Module [{$name}] updated successfully."); }
/** * Publish migration for the specified module. * * @param Module $module */ private function publish(Module $module) { (new MigrationPublisher($module))->setWorkbench(workbench())->setConsole($this)->publish(); }
/** * Install the specified module. * * @param string $name * @param string $version * @param string $type * @param bool $tree */ private function install($name, $version = 'dev-master', $type = 'composer', $tree = false) { $installer = new Installer($name, $version, $type ?: $this->getStringOption('type'), $tree ?: $this->getBoolOption('tree')); $installer->setRepository(workbench()); $installer->setConsole($this); if ($timeout = $this->option('timeout')) { $installer->setTimeout((int) $timeout); } if ($path = $this->getStringOption('path')) { $installer->setPath($path); } $installer->run(); if (!$this->option('no-update')) { $this->call('module:update', ['module' => $installer->getModuleName()]); } }
/** * Register the service provider. * * @return void */ public function register() { workbench()->register(); }
/** * Get migration generator path. * * @return string */ protected function getMigrationGeneratorPath() { return workbench()->config('paths.generator.migration'); }
/** * Get template contents. * * @return string */ protected function getTemplateContents() { return Stub::create('/seeder.stub', ['NAME' => $this->getFileName(), 'MODULE' => $this->getModuleName(), 'MODULE_NAMESPACE' => workbench()->config('namespace')])->render(); }
/** * Get template contents. * * @return string */ protected function getTemplateContents() { $stub = ($this->option('master') == 'scaffold' ? 'scaffold/' : '') . 'provider'; $module = workbench()->findOrFail($this->getModuleName()); return Stub::create('/' . $stub . '.stub', ['NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), 'LOWER_NAME' => $module->getLowerName()])->render(); }
/** * Publish assets from the specified module. * * @param Module|string $name */ private function publish($name) { $module = $name instanceof Module ? $name : workbench()->findOrFail($name); (new AssetPublisher($module))->setWorkbench(workbench())->setConsole($this)->publish(); $this->line("<info>Published</info>: {$module->getStudlyName()}"); }
/** * Get master database seeder name for the specified module. * * @param string $name * * @return string */ private function getSeederName($name) { $name = str_studly($name); $namespace = workbench()->config('namespace'); return $namespace . '\\' . $name . '\\Database\\Seeders\\' . $name . 'DatabaseSeeder'; }