/** * 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(); }
/** * Get template replacements. * * @return array */ public function getReplacements() { $replacements = array_merge(parent::getReplacements(), ['root_namespace' => $this->getAppNamespace()]); if ($this->scaffold) { return array_merge($replacements, $this->scaffolder->toArray()); } return $replacements; }
/** * 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 stub replacements. * * @return array */ public function getReplacements() { return array_merge(parent::getReplacements(), ['table_one' => $this->table_one, 'table_two' => $this->table_two, 'column_one' => $this->getColumnOne(), 'column_two' => $this->getColumnTwo(), 'table_pivot' => $this->getPivotTableName(), 'timestamp' => $this->getTimestampReplacement()]); }
/** * Get stub replacements. * * @return array */ public function getReplacements() { return array_merge(parent::getReplacements(), ['auth' => $this->getAuth(), 'rules' => $this->getRules()]); }