예제 #1
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();
 }
예제 #2
0
 /**
  * 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();
 }