/** * Get stub templates. * * @return string */ public function getStub() { $parser = $this->getNameParser(); $action = $parser->getAction(); switch ($action) { case 'add': case 'append': case 'update': case 'insert': $file = 'change'; $replacements = ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields_up' => $this->getSchemaParser()->up(), 'fields_down' => $this->getSchemaParser()->down()]; break; case 'delete': case 'remove': case 'alter': $file = 'change'; $replacements = ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields_down' => $this->getSchemaParser()->up(), 'fields_up' => $this->getSchemaParser()->down()]; break; default: $file = 'create'; $replacements = ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields' => $this->getSchemaParser()->up()]; break; } $path = config('repository.generator.stubsOverridePath', __DIR__); if (!file_exists($path . "/Stubs/migration/{$file}.stub")) { $path = __DIR__; } if (!file_exists($path . "/Stubs/migration/{$file}.stub")) { throw new FileNotFoundException($path . "/Stubs/migration/{$file}.stub"); } return Stub::create($path . "/Stubs/migration/{$file}.stub", $replacements); }
/** * Get stub templates. * * @return string */ public function getStub() { $parser = $this->getNameParser(); return Stub::create(__DIR__ . '/Stubs/migration/add.stub', ['class' => $this->getClass(), 'table' => $parser->getTable(), 'fields_up' => $this->getSchemaParser()->up(), 'fields_down' => $this->getSchemaParser()->down()]); }