Saves the model content for a table.
@return MakeMWBModel
343240
protected function saveModelForTable()
    {
        $table = $this;
        $dates = [];
        $fields = $table->getFields();
        // TODO Work with the namespace again. The FQN does not work since switching to the generator.s
        $modelContent = (new ModelContent($table->getModelName()))->setTable($table->getName());

        if (array_key_exists($field = 'deleted_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
            $modelContent->setTraits(['\Illuminate\Database\Eloquent\SoftDeletes']);
        } // if

        if (array_key_exists($field = 'created_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if (array_key_exists($field = 'updated_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if ($dates) {
            $modelContent->setDates($dates);
        } // if

        unset($fields['id']);
        $modelContent->setFillable(array_diff(array_keys($fields), $table->getBlacklist()));
        $modelContent->setCasts($table->getCastedFields());

        if ($genericCalls = $table->getGenericCalls()) {
            foreach ($genericCalls as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        if ($sources = $table->getRelationSources()) {
            foreach ($sources as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        $modelContent->save();

        return $this;
    }
494241
public function actionCreate()
    {
        // 1. ask for module
        if ($this->moduleName === null) {
            Console::clearScreenBeforeCursor();
            $this->moduleName = $this->selectModule(['onlyAdmin' => $this->hideFrontendModules, 'hideCore' => $this->hideCoreModules, 'text' => 'Select the Module where the CRUD files should be saved:']);
        }
        
        // 2. ask for sql table
        if ($this->dbTableName === null) {
            $this->dbTableName = $this->prompt('Enter the name of the database table to generate the model for (? to see all tables):', ['required' => true, 'validator' => function ($input, &$error) {
                if ($input == '?') {
                    foreach ($this->getSqlTablesArray() as $table) {
                        $this->outputInfo("- " . $table);
                    }
                    return false;
                }
                
                if (!isset($this->getSqlTablesArray()[$input])) {
                    $error = "Table '$input' does not exists. Type '?' to see all tables.";
                    return false;
                }
                
                return true;
            }]);
        }
        
        // 3. ask for model name
        if ($this->modelName === null) {
            $modelSelection = true;
            while ($modelSelection) {
                $modelName = $this->prompt('Model Name (e.g. Album):', ['required' => true, 'default' => $this->getModelNameSuggestion()]);
                $camlizeModelName = Inflector::camelize($modelName);
                if ($modelName !== $camlizeModelName) {
                    if ($this->confirm("We have camlized the model name to '$camlizeModelName' do you want to continue with this name?")) {
                        $modelName = $camlizeModelName;
                        $modelSelection = false;
                    }
                } else {
                    $modelSelection = false;
                }
                $this->modelName = $modelName;
            }
        }
        
        // 4. ask for api endpoint name
        if ($this->apiEndpoint === null) {
            $this->apiEndpoint = $this->prompt('Api Endpoint:', ['required' => true, 'default' => $this->getApiEndpointSuggestion()]);
        }

        // 5. ask for i18n
        if ($this->enableI18n === null) {
            $this->enableI18n = $this->confirm("Would you like to enable i18n field input for text fields? Only required for multilingual pages.");
        }

        $this->ensureBasePathAndNamespace();
        
        $files = [];
        
        // api content

        $files['api'] = [
            'path' => $this->getBasePath() . DIRECTORY_SEPARATOR . 'apis',
            'fileName' => $this->getModelNameCamlized() . 'Controller.php',
            'content' => $this->generateApiContent($this->getNamespace() . '\\apis', $this->getModelNameCamlized() . 'Controller', $this->getAbsoluteModelNamespace()),
        ];
        
        // controller

        $files['controller'] = [
            'path' =>  $this->getBasePath() . DIRECTORY_SEPARATOR . 'controllers',
            'fileName' => $this->getModelNameCamlized() . 'Controller.php',
            'content' => $this->generateControllerContent($this->getNamespace() . '\\controllers', $this->getModelNameCamlized() . 'Controller', $this->getAbsoluteModelNamespace()),
        ];
        
        // model

        $files['model'] = [
            'path' =>  $this->getModelBasePath() . DIRECTORY_SEPARATOR . 'models',
            'fileName' => $this->getModelNameCamlized() . '.php',
            'content' => $this->generateModelContent(
                $this->getModelNamespace() . '\\models',
                $this->getModelNameCamlized(),
                $this->apiEndpoint,
                $this->getDbTableShema(),
                $this->enableI18n
             ),
        ];
        
        foreach ($files as $file) {
            $this->generateFile($file);
        }
        
        return $this->outputSuccess($this->generateBuildSummery($this->apiEndpoint, $this->getNamespace() . '\\apis\\' . $this->getModelNameCamlized() . 'Controller', $this->getModelNameCamlized(), $this->getSummaryControllerRoute()));
    }
1248190
public function save () {
		if (isset ($this->_data['id'])) {
			return $this->_send_and_receive ($this->site . $this->element_name_plural . '/' . $this->_data['id'] . '.xml', 'PUT', $this->_data); // update
		}
		return $this->_send_and_receive ($this->site . $this->element_name_plural . '.xml', 'POST', $this->_data); // create
	}
577768
public function save()
    {
        $contents = array_filter($this->contents);

        if (empty($contents)) {
            return;
        }

        if (!file_exists($this->filepath)) {
            mkdir($this->filepath);
        }

        return (new YamlFilesystem($contents, $this->filepath))
            ->save(static::FILE_NAME);
    }
272752
public function saveToModel(Model $model, Request $request)
    {
        $this->setModel($model);

        $model->setAttribute($this->getFieldName(), $this->getSaveValue($request));

        return $this;
    }
971372
public function save(){
        $this->_contentArray =  array_merge($this->_codesBeforeEditArea, $this->_editArea, $this->_codesAfterEditArea);
        return $this;
    }
321877
public function save()
    {
        $sQuery = $this->_prepare();

        if (preg_match('/INSERT INTO/i', $sQuery)) {

            $oDb = self::connect();

            if (!$oDb->exec($sQuery)) {
                error_log($sQuery."\n".print_r($oDb->errorInfo(), true));
            }

            $this->flush();
            return $oDb->lastInsertId();
        }
        else {

            $this->flush();

            if ($this->_mWhere instanceof Where) { $this->_mWhere->flush(); }

            return self::connect()->exec($sQuery);
        }

    }
1043393
protected function save()
    {
        $this->db->createCommand()->update($this->tableName, [
            'updated_at' => time(),
            'data' => [serialize($this->_states), \PDO::PARAM_LOB],
            ], ['id' => $this->_id])->execute();
    }
709007
public function _saveArray()
	{
		$value = $this->getModel()->getAttribute($this->getArrayFieldName());;
		$value = $this->_postgresqlArrayEncode($value);
		if($value === null && $this->onEmptySaveNull == false){
			$value = '{}';
		}
		$this->getModel()->setAttribute($this->getArrayFieldName(), $value);

		return $this;
	}
120077
public function save()
    {
        $oVendor = oxNew(\OxidEsales\Eshop\Core\Model\BaseModel::class);
        $oVendor->init('oxvendor');
        if ($oVendor->load($this->getEditObjectId())) {
            $sShowSuffixField = 'oxvendor__oxshowsuffix';
            $blShowSuffixParameter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('blShowSuffix');
            $oVendor->$sShowSuffixField = new \OxidEsales\Eshop\Core\Field((int) $blShowSuffixParameter);
            $oVendor->save();
        }

        return parent::save();
    }
874004
protected function createOutputContents()
    {
        $dom = $this->formatterInstance()
                    ->forge(
                        $this->rows,
                        $this->rootElementName,
                        $this->replaceSpacesByUnderScoresInKeyNames,
                        $this->versionOfXmlDeclaration,
                        $this->encodingOfXmlDeclaration
                    )->toDom();

        $dom->formatOutput = $this->formatOutput;

        return $dom->saveXML();
    }
596652
public function save(LayoutModel $model)
    {
        $record = LayoutRecord::findOne(['id' => $model->id]);

        if (!$record) {
            $record = new LayoutRecord();
        }

        $model->validate();

        if ($model->hasErrors()) {
            return false;
        }

        $record->name = $model->name;
        $record->permissions = $model->permissions;
        $record->validate();

        if ($record->hasErrors()) {
            $model->addErrors($record->getErrors());

            return false;
        }

        if (!$record->save()) {
            return false;
        }

        if (!$model->id) {
            $model->id = $record->id;
        }

        return $model;
    }
479316
protected function handleModelTables()
    {
        if (!$this->getModelReader()->isCompatibleVersion()) {
            throw new \InvalidArgumentException('Wrong model version.');
        } // if

        $bar = $this->output->createProgressBar();

        $bar->start(count($tables = $this->getModelTables()));

        /** @var TableMigration $tableObject */
        foreach ($this->createTableRelations($tables) as $tableObject) {
            $tableObject->save($this);

            $bar->advance();
        } // foreach

        return $this;
    }
1161393
public function save()
    {
        $file = $this->createMigrationFile();

        if (!$written = !$file) {
            $written = $this->addCallsToMigrationFile($file);
        }

        if ($this->needsLaravelModel()) {
            $this->saveModelForTable();
        }

        return $written;
    }
1189029
public function save()
        {
            $query = [];

            // remove any expression fields as they are already baked into the query
            $values = array_values(array_diff_key($this->_dirty_fields, $this->_expr_fields));

            if (!$this->_is_new) { // UPDATE
                // If there are no dirty values, do nothing
                if (empty($values) && empty($this->_expr_fields)) {
                    return true;
                }

                $query = $this->_buildUpdate();
                $id = $this->id(true);

                if (Arrays::is($id)) {
                    $values = array_merge($values, array_values($id));
                } else {
                    $values[] = $id;
                }
            } else { // INSERT
                $query = $this->_buildInsert();
            }

            $success = self::_execute($query, $values, $this->_connection_name);
            $caching_auto_clear_enabled = self::$_config[$this->_connection_name]['caching_auto_clear'];

            if ($caching_auto_clear_enabled){
                self::clear_cache($this->_table_name, $this->_connection_name);
            }

            // If we've just inserted a new record, set the ID of this object
            if ($this->_is_new) {
                $this->_is_new = false;

                if ($this->count_null_id_columns() != 0) {
                    $db = self::get_db($this->_connection_name);

                    if($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
                        // it may return several columns if a compound primary
                        // key is used
                        $row = self::get_last_statement()->fetch(PDO::FETCH_ASSOC);

                        foreach($row as $key => $value) {
                            $this->_data[$key] = $value;
                        }
                    } else {
                        $column = $this->_getIdColumnName();
                        // if the primary key is compound, assign the last inserted id
                        // to the first column

                        if (Arrays::is($column)) {
                            $column = array_slice($column, 0, 1);
                        }

                        $this->_data[$column] = $db->lastInsertId();
                    }
                }
            }

            $this->_dirty_fields = $this->_expr_fields = [];

            return $success;
        }
92468
public function saveSeoContent() {
		$model = $this->getSeoContentModel();
		if (!$model->is_global) {
			$model->title = $this->owner->{$this->titleAttribute};
			$model->keywords = $this->owner->{$this->keywordsAttribute};
			$model->description = $this->owner->{$this->descriptionAttribute};
			$model->save();
		}
	}
102241
public function save()
    {
        $this->hook('beforeSave', array($this->id));

        $is_update = $this->loaded();
        if ($is_update) {
            $source = array();
            foreach ($this->dirty as $name => $junk) {
                $source[$name] = $this->get($name);
            }

            // No save needed, nothing was changed
            if (empty($source)) {
                return $this;
            }

            $this->hook('beforeUpdate', array(&$source));
        } else {

            // Collect all data of a new record
            $source = $this->get();

            $this->hook('beforeInsert', array(&$source));
        }

        if ($this->controller) {
            $this->id = $this->controller->save($this, $this->id, $source);
        }

        if ($is_update) {
            $this->hook('afterUpdate');
        } else {
            $this->hook('afterInsert');
        }

        if ($this->loaded()) {
            $this->dirty = array();
            $this->hook('afterSave', array($this->id));
        }

        return $this;
    }