Example #1
0
 /**
  * Get stub template.
  *
  * @param string $type
  * @param string $name
  *
  * @return string
  */
 public function getStub($type, $name)
 {
     if (in_array($name, $this->ignores)) {
         return;
     }
     $type = $this->getInputType($type, $name);
     return Stub::createFromPath(__DIR__ . '/../Stubs/form/' . $type . '.stub', ['name' => $name, 'label' => ucwords($name)])->render();
 }
 /**
  * Get stub templates.
  *
  * @return string
  */
 public function getStub()
 {
     if ($this->action == 'create') {
         return Stub::createFromPath(__DIR__ . '/../Stubs/migration/create.stub', ['class' => $this->getClass(), 'table' => $this->table->getName(), 'fields' => $this->constructSchema()]);
     } elseif ($this->action == 'create_simple') {
         return Stub::createFromPath(__DIR__ . '/../Stubs/migration/create_simple.stub', ['class' => $this->getClass(), 'table' => $this->table->getName(), 'fields' => $this->constructSchema()]);
     } elseif ($this->action == 'add') {
         return Stub::createFromPath(__DIR__ . '/../Stubs/migration/add.stub', ['class' => $this->getClass(), 'table' => $this->table->getName(), 'fields_up' => $this->constructSchema(), 'fields_down' => $this->constructSchema('drop')]);
     } elseif ($this->action == 'delete') {
         return Stub::createFromPath(__DIR__ . '/../Stubs/migration/delete.stub', ['class' => $this->getClass(), 'table' => $this->table->getName(), 'fields_down' => $this->constructSchema(), 'fields_up' => $this->constructSchema('drop')]);
     } elseif ($this->action == 'drop') {
         return Stub::createFromPath(__DIR__ . '/../Stubs/migration/drop.stub', ['class' => $this->getClass(), 'table' => $this->table->getName(), 'fields' => $this->constructSchema()]);
     }
     return parent::getStub();
 }
Example #3
0
 /**
  * Get replacements for $SHOW_BODY$.
  *
  * @param string $var
  *
  * @return string
  */
 public function toRows($var)
 {
     $results = PHP_EOL;
     foreach ($this->fields as $field) {
         if (in_array($field->getName(), $this->ignores)) {
             continue;
         }
         $results .= Stub::createFromPath(__DIR__ . '/../Stubs/scaffold/row.stub', ['label' => ucwords($field->getName()), 'column' => $field->getName(), 'var' => $var])->render();
     }
     return $results . PHP_EOL;
 }
Example #4
0
 /**
  * Get replacements for $SHOW_BODY$.
  *
  * @param string $var
  *
  * @return string
  */
 public function toRows($var)
 {
     $results = PHP_EOL;
     foreach ($this->getColumns() as $column) {
         if (in_array($name = $column->getName(), $this->ignores)) {
             continue;
         }
         $results .= Stub::create(__DIR__ . '/../Stubs/scaffold/row.stub', ['label' => ucwords($name), 'column' => $name, 'var' => $var])->render();
     }
     return $results . PHP_EOL;
 }
Example #5
0
 /**
  * Get stub template for generated file.
  *
  * @return string
  */
 public function getStub()
 {
     $stub = new Stub($this->stub . '.stub', $this->getReplacements());
     $stub->setBasePath(__DIR__ . '/../Stubs/');
     return $stub->render();
 }