Beispiel #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();
 }
 /**
  * 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();
 }
Beispiel #3
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;
 }