Esempio n. 1
0
 /**
  * Get stub template.
  *
  * @param  string $type
  * @param  string $name
  *
  * @return string|null
  */
 public function getStub($type, $name)
 {
     if (in_array($name, $this->ignores)) {
         return null;
     }
     $type = $this->getInputType($type, $name);
     return Stub::createFromPath(__DIR__ . '/../../stubs/form/' . $type . '.stub', ['name' => $name, 'label' => ucwords(str_replace('_', ' ', $name))])->render();
 }
Esempio n. 2
0
 /**
  * Get stub template for generated file.
  *
  * @return string
  */
 public function getStub()
 {
     if ($this->plain) {
         return $this->getPath();
     }
     if ($template = $this->template) {
         return Stub::create($template, $this->getReplacements())->render();
     }
     return parent::getStub();
 }
 /**
  * Get template contents.
  *
  * @throws InvalidMigrationNameException
  *
  * @return string
  */
 protected function getTemplateContents()
 {
     $parser = new NameParser($this->getStringArg('name'));
     if ($parser->isCreate()) {
         return Stub::create('/migration/create.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields' => $this->getSchemaParser()->render()])->render();
     } elseif ($parser->isAdd()) {
         return Stub::create('/migration/add.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields_up' => $this->getSchemaParser()->up(), 'fields_down' => $this->getSchemaParser()->down()])->render();
     } elseif ($parser->isDelete()) {
         return Stub::create('/migration/delete.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields_down' => $this->getSchemaParser()->up(), 'fields_up' => $this->getSchemaParser()->down()])->render();
     } elseif ($parser->isDrop()) {
         return Stub::create('/migration/drop.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields' => $this->getSchemaParser()->render()])->render();
     }
     throw new InvalidMigrationNameException();
 }
Esempio n. 4
0
 /**
  * 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();
 }
Esempio n. 5
0
 /**
  * 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();
 }
 /**
  * Get stub templates.
  *
  * @return string
  */
 public function getStub()
 {
     $parser = $this->getNameParser();
     if ($parser->isCreate()) {
         return Stub::createFromPath(__DIR__ . '/../../stubs/migration/create.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields' => $this->getSchemaParser()->render()]);
     } elseif ($parser->isAdd()) {
         return Stub::createFromPath(__DIR__ . '/../../stubs/migration/add.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields_up' => $this->getSchemaParser()->up(), 'fields_down' => $this->getSchemaParser()->down()]);
     } elseif ($parser->isDelete()) {
         return Stub::createFromPath(__DIR__ . '/../../stubs/migration/delete.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields_down' => $this->getSchemaParser()->up(), 'fields_up' => $this->getSchemaParser()->down()]);
     } elseif ($parser->isDrop()) {
         return Stub::createFromPath(__DIR__ . '/../../stubs/migration/drop.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields' => $this->getSchemaParser()->render()]);
     }
     return parent::getStub();
 }
Esempio n. 7
0
 /**
  * Get replacements for $SHOW_BODY$.
  *
  * @param string $var
  *
  * @return string
  */
 public function toRows($var)
 {
     $results = PHP_EOL;
     foreach ($this->getColumns() as $column) {
         /** @var Column $column */
         $name = $column->getName();
         if (!in_array($name, $this->ignores)) {
             $results .= Stub::create(__DIR__ . '/../../stubs/scaffold/row.stub', ['label' => ucwords($name), 'column' => $name, 'var' => $var])->render();
         }
     }
     return $results . PHP_EOL;
 }
 /**
  * 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();
 }
 /**
  * Setup stub path.
  */
 private function registerStubs()
 {
     $this->app->booted(function ($app) {
         /** @var \Illuminate\Config\Repository $config */
         $config = $app['config'];
         $path = $this->getBasePath() . DS . 'stubs';
         if ($config->get('workbench.stubs.enabled', false) === true) {
             $path = (string) $config->get('workbench.stubs.path', $path);
         }
         Stub::setBasePath($path);
     });
 }
Esempio n. 10
0
 /**
  * Get stub template for generated file.
  *
  * @return string
  */
 public function getStub()
 {
     $stub = Stub::create($this->stub . '.stub', $this->getReplacements());
     $stub->setBasePath(__DIR__ . '/../../stubs/');
     return $stub->render();
 }
Esempio n. 11
0
 /**
  * Get template contents
  *
  * @return mixed
  */
 protected function getTemplateContents()
 {
     return Stub::create('/command.stub', ['COMMAND_NAME' => $this->getCommandName(), 'NAMESPACE' => $this->getClassNamespace($this->getModule()), 'CLASS' => $this->getClass()])->render();
 }
Esempio n. 12
0
 /**
  * Get replacements for $SHOW_BODY$.
  *
  * @param string $var
  *
  * @return string
  */
 public function toRows($var)
 {
     $results = PHP_EOL;
     foreach ($this->getParser()->toArray() as $name => $types) {
         if (!in_array($name, $this->ignores)) {
             $results .= Stub::createFromPath(__DIR__ . '/../../stubs/scaffold/row.stub', ['label' => ucwords($name), 'column' => $name, 'var' => $var])->render();
         }
     }
     return $results . PHP_EOL;
 }
 /**
  * Get template contents.
  *
  * @return string
  */
 protected function getTemplateContents()
 {
     return Stub::create('/middleware.stub', ['NAMESPACE' => $this->getClassNamespace($this->getModule()), 'CLASS' => $this->getClass()])->render();
 }