Create a new object from this model.

@param array $values Array of keys as fields and values.
@param boolean $save If the object should be immediately saved to database before being returned.
@return static An object of this model.
347801
public static function create($values = [], $save = false)
    {
        $className = get_called_class();

        // create class
        $ActiveRecord = new $className();
        $ActiveRecord->setFields($values);

        if ($save) {
            $ActiveRecord->save();
        }

        return $ActiveRecord;
    }
690131
public function set($key, $value, $save = true)
    {
        $this->load();
        NestedArrayUtil::setNestedArrayValue($this->state, explode('.', $key), $value);
        if ($save) {
            $this->save();
        }
    }
1204008
public function values($values)
    {
        if(!$values instanceof DatabaseQuerySelect)
        {
            if (!$this->columns && !is_numeric(key($values))) {
                $this->columns(array_keys($values));
            }

            $this->values[] = array_values($values);
        }
        else $this->values = $values;

        return $this;
    }
227306
protected static function exeCreate(string $entity, array $data, bool $save)
    {
        $dicionario = new Dicionario($entity);
        $dicionario->setData($data);

        if ($save)
            $dicionario->save();

        return self::return($dicionario);
    }
93266
public function new(array $attributes = [], bool $exists = false): Model{
        return $this->model->newInstance($attributes, $exists);
    }
1353347
protected function createObjectFromArray(array &$value)
    {
        if (array_key_exists('$ref', $value) && is_string($value['$ref'])) {
            return $this->createReferenceFromArray($value);
        }

        $instance = new Value\ObjectValue;
        $this->register($value, $instance);

        foreach ($value as $key => &$subValue) {
            $instance->set($key, $this->createValue($subValue));
        }

        return $instance;
    }
835315
public function create(array $attributes = [], array $properties = array())
    {
        // Here we will set the raw attributes to avoid hitting the "fill" method so
        // that we do not have to worry about a mass accessor rules blocking sets
        // on the models. Otherwise, some of these attributes will not get set.
        $instance = $this->related->newInstance($attributes);

        return $this->save($instance, $properties);
    }
433440
public function load_values(array $values, $clean = FALSE)
  {
    if($clean === TRUE)
    {
      $this->before_load();

      $this->_object = $values;
      $this->_loaded = ! empty($this->_object);

      $this->after_load();
    }
    else
    {
      foreach ($values as $field => $value)
      {
        $this->__set($field, $value);
      }
    }

    return $this;
  }
547103
public static function createOne(array $attributes)
    {
        return tap(new self($attributes), function (self $post) use ($attributes) {
            $post->save();

            $post->tags()->sync($attributes['tags']);

            $post->createSeo(
                static::extractSeoAttributes($attributes)
            );
        });
    }
967188
public function create(array $attributes): bool
    {
        $model = $this->getModel();
        $model->setAttributes($attributes);

        return $model->save();
    }
161661
public static function create($values = null, $map = null, $prefix = null)
    {
        $object = new static();
        if ($values) {
            $object->fillSchemaFields($values, $map, $prefix);
        }

        return $object;
    }
1233150
public function firstOrNew(array $attributes, array $values = [])
    {
        if (is_null($instance = $this->where($attributes)->first())) {
            $instance = $this->related->newInstance($attributes + $values);

            $this->setForeignAttributesForCreate($instance);
        }

        return $instance;
    }
329796
public function create($attributes = array())
    {
        $entity = $this->build($attributes);

        // to SQL.
        $criteria = $this->criteria();
        $sql = $criteria->toInsertSQL($attributes);

        // query.
        $sth = $this->query($sql, $criteria->getParams(), Database::TARGET_MASTER);
        if ($sth->isSuccess()) {
            $entity->exists = true;
            $entity->setPrimaryValue($sth->lastInsertId());
            return $entity;
        }
    }
113686
public function entityCreate($entity_type, $values, $save = TRUE) {
    if (!is_array($values)) {
      // Cast an object to array to be compatible with nodeCreate().
      $values = (array) $values;
    }

    $entity = $this->getStubEntity($entity_type, $values);

    foreach ($values as $name => $value) {
      $definition = $entity->getFieldDefinition($name);
      $settings = $definition->getSettings();
      switch ($definition->getType()) {
        case 'entity_reference':
          if (in_array($settings['target_type'], ['node', 'taxonomy_term'])) {
            // @todo: only supports single values for the moment.
            $id = $this->getEntityIdByLabel($settings['target_type'], NULL, $value);
            $entity->{$name}->setValue($id);
          }
          break;

        case 'entity_reference_revisions':
          $entities = [];
          foreach ($value as $target_values) {
            Assert::keyExists($target_values, 'type', __METHOD__ . ": Required fields 'type' not found.");
            $entities[] = $this->entityCreate($settings['target_type'], $target_values, FALSE);
          }

          $entity->{$name}->setValue($entities);
          break;

        case 'image':
          $entity->{$name}->setValue(['target_id' => $this->saveFile($value)->id()]);
          break;
      }
    }

    if ($save) {
      $entity->save();
    }

    return $entity;
  }
1327512
public function create(array $attributes)
	{
		$foreign = array(
			$this->getPlainForeignKey() => $this->getParentKey(),
		);

		// Here we will set the raw attributes to avoid hitting the "fill" method so
		// that we do not have to worry about a mass accessor rules blocking sets
		// on the models. Otherwise, some of these attributes will not get set.
		$instance = $this->related->newInstance();

		$instance->setRawAttributes(array_merge($attributes, $foreign));

		$instance->save();

		return $instance;
	}
592049
function copy() {
		$new_object = new static();
		$values = $this->toArray();

		foreach (static::$_primaryKeys as $pk) {
			unset($values[$pk]);
		}

		$new_object->fromArray($values);
		return $new_object;
	}
721564
public function fromArray(array $values)
    {
        foreach ($values as $property => $value) {
            $this->__set($property, $value);
        }
        
        return $this;
    }