/** * @throws InvalidMigrationName * @return mixed */ protected function getTemplateContents() { $schema = new Parser($this->argument('name')); $fields = new Field($this->option('fields')); if ($this->option('plain')) { return new Stub('migration/plain', ['CLASS' => $this->getClassName()]); } elseif ($schema->isCreate()) { return new Stub('migration/create', ['CLASS' => $this->getClassName(), 'FIELDS' => $fields->getSchemaCreate(), 'TABLE' => $schema->getTableName()]); } elseif ($schema->isAdd()) { return new Stub('migration/add', ['CLASS' => $this->getClassName(), 'FIELDS_UP' => $fields->getSchemaCreate(), 'FIELDS_DOWN' => $fields->getSchemaDropColumn(), 'TABLE' => $schema->getTableName()]); } elseif ($schema->isDelete()) { return new Stub('migration/delete', ['CLASS' => $this->getClassName(), 'FIELDS_DOWN' => $fields->getSchemaCreate(), 'FIELDS_UP' => $fields->getSchemaDropColumn(), 'TABLE' => $schema->getTableName()]); } elseif ($schema->isDrop()) { return new Stub('migration/drop', ['CLASS' => $this->getClassName(), 'FIELDS' => $fields->getSchemaCreate(), 'TABLE' => $schema->getTableName()]); } throw new InvalidMigrationName(); }