Saves a new related model with the given data

@param   array  $data  The data being saved on the new model
@return  bool
@since   2.0.0
961169
public function save($data)
	{
		$related = $this->related;
		$model   = $related::newFromResults($data);

		return $this->associate($model)->save();
	}
343864
public function setData(array $data): self
    {
        list($this->foreignKeys, $this->belongsToMany, $this->relationshipTypes,
            $this->reversedRelationships,$this->tableNames, $this->primaryKeys,
            $this->attributeTypes, $this->attributeLengths, $this->attributes, $this->rawAttributes,
            $this->reversedClasses) = $data;

        return $this;
    }
130656
protected function _insert(array $data)
    {
        $data = $this->_setData($data);
        $sql = Sql::createSql($this->getAdapter())->insert($this->getTableName());
        $event = new Save([
            'action' => Save::INSERT,
            'data' => $data,
            'abort' => false
        ]);
        $this->getEventManager()->trigger(Save::BEFORE_SAVE, $this, $event);
        if ($event->abort) {
            return false;
        }
        $result = $sql->set($event->data)->execute();

        if ($result > 0) {
            $pmk = $this->getPrimaryKey();
            $this->$pmk = $this->getAdapter()->getLastInsertId();
            $this->getEventManager()->trigger(Save::AFTER_SAVE, $this, $event);
        }
        return $result > 0;
    }
104499
public function save($options = [])
    {
        foreach ($this->relations as $related) {
            if (!$related->save()) {
                $this->throwSaveError($related);
            }
        }

        if (!$this->data->save($options)) {
            $this->throwSaveError($this->data);
        }

        $this->data = $this->data->fresh();

        return true;
    }
1205611
public function saveRawData( array $data )
    {
        if ( ! parent::save( $data ) )
        {
            return null;
        }

        return isset( $data['id'] ) ? $data['id'] : null;
    }
647692
public function put($data = [])
	{
		if (empty($data))
			return false;

		$this->setData();

		$data = (array) $data;

		foreach ($data as $name => $value)
			$this->_request[$name] = $_REQUEST[$name] = $this->sanitize($value);

		return $this->_request;
	}
663694
public function save($data)
	{
		// Check and make sure this is an array of arrays
		if (!is_array($data))
		{
			return false;
		}

		if (isset($data[0]) && is_array($data[0]))
		{
			foreach ($data as $d)
			{
				if (!parent::save($d))
				{
					return false;
				}
			}
		}
		else
		{
			// If not an array of arrays, we'll assume it's just one item to save
			if (!parent::save($data))
			{
				return false;
			}
		}

		return true;
	}
184351
public function save(array $data)
    {
        if (!$this->getModel()->isSingle()) {
            $id = $data['id'] ?? $this->id;
            $this->id = $id;
        }

        $columns = $this->data;
        foreach ($columns as $key => $column) {
            if (array_key_exists($key, $data)) {
                $column->setValue($data[$key]);
            } else {
                $column->setValue(null);
            }
        }

        $yaml = Yaml::dump($this->getData(), 5, 4, YAML::DUMP_MULTI_LINE_LITERAL_BLOCK | YAML::DUMP_OBJECT_AS_MAP);

        $fs = new Filesystem();
        $fs->dumpFile($this->getContentFilePath(), $yaml);
    }
712390
public static function create(array $data): Model
    {
        $insert = new Insert(static::getTableName(), $data, static::getAdapterConnection());
        $insert->exec();

        if (static::$autoIncrement) {
            // ID should be fetched if $data contains ID, so, let's check
            if (is_string(static::$primaryKey) && isset($data[static::$primaryKey])) {
                // there there, we already have it, let's do nothing
            } else {
                $data[static::$primaryKey] = static::getLastInsertId();
            }
        }

        return new static($data);
    }
152288
public function createNewRecord($data) {
        $people_email = new $this->model;

        $people_email['people_id']     = $data['people_id'];
        $people_email['email_id']      = $data['email_id'];

        if ($people_email->save()) {

            // Return the new ID
            return $people_email->id;
        }

        return false;
    }
1208427
public function createNewRecord($data) {
        $people = new $this->model;

        $people['user_id']        = $data['user_id'];
        $people['title']          = $data['title'];
        $people['salutation']     = $data['salutation'];
        $people['first_name']     = $data['first_name'];
        $people['middle_name']    = $data['middle_name'];
        $people['surname']        = $data['surname'];
        $people['position']       = $data['position'];
        $people['description']    = $data['description'];
        $people['comments']       = $data['comments'];

        $people['birthday']       = $data['birthday'];
        $people['anniversary']    = $data['anniversary'];

        $people['created_at']     = $data['created_at'];
        $people['created_by']     = $data['created_by'];
        $people['updated_at']     = $data['updated_at'];
        $people['updated_by']     = $data['updated_by'];

        $people['profile']        = $data['profile'];
        $people['featured_image'] = $data['featured_image'];

        if ($people->save()) {

            // Return the new ID
            return $people->id;
        }

        return false;
    }
882609
final public function save(array $data)
    {
        return array_key_exists('id', $data) ?
            $this->update($data) :
            $this->insert($data);
    }
180452
protected function save($data)
    {
        $currentStep = $this->getCurrentStep();
        if (is_array($data)) {
            foreach ($data as $field => $value) {
                if (in_array($field, $this->config()->get('ignored_fields'))) {
                    unset($data[$field]);
                }
            }
            $currentStep->saveData($data);
        }
        return;
    }
604725
public function save($data)
    {
        if (is_array($data)) {
            foreach ($data as $entity) {
                $this
                    ->manager
                    ->persist($entity);
            }
        } else {
            $this
                ->manager
                ->persist($data);
        }

        $this
            ->manager
            ->flush($data);

        return $data;
    }
1291467
public function save($data)
    {
        if ($data instanceof Model) {
            $data = $data->getData();
        }
        // 保存关联表数据
        $pk = $this->parent->getPk();

        $model = new $this->model;

        $data[$this->morphKey]  = $this->parent->$pk;
        $data[$this->morphType] = $this->type;
        return $model->save($data) ? $model : false;
    }
971496
protected function _update(array $data)
    {
        $data = $this->_setData($data);
        $pmk = $this->getPrimaryKey();
        unset($data[$pmk]);
        $sql = Sql::createSql($this->getAdapter())->update($this->getTableName());
        $event = new Save([
            'action' => Save::UPDATE,
            'data' => $data,
            'abort' => false
        ]);
        $this->getEventManager()->trigger(Save::BEFORE_SAVE, $this, $event);
        if ($event->abort) {
            return false;
        }
        $sql->set($event->data)
            ->where(["{$pmk} = :id" => [':id' => $this->$pmk]])
            ->execute();
        $this->getEventManager()->trigger(Save::AFTER_SAVE, $this, $event);
        return true;
    }
701419
static public function create(array $data)
    {
        $class = static::$modelClass;

        /** @var \Illuminate\Database\Eloquent\Model $model */
        $model = new $class;

        // set primarye key
        if(static::isUuid() && empty($data[$model->getKeyName()])) {
            $data[$model->getKeyName()] = uuid();
        }

        $model = $class::create($data);

        return static::get($model->getKey());
    }