@param array $data

@return Model|\stdClass
182828
public function create(array $data): Model
    {
        $result = $this->repo->create($data);
        $pid = empty($data['pid']) ? 0 : $data['pid'];


        if ((int)$pid !== 0) {
            // 计算根id
            $parent = $this->show($data['pid']);
            $rootId = $parent->root_id;
            // 计算深度
            $deep = (int)$parent->deep + 1;
            // 计算path
            $path = $parent->path . $result->id . ",";
        } else {
            // 计算根id
            $rootId = $result->id;
            // 计算深度
            $deep = 0;
            // 计算path
            $path = "," . $result->id . ",";
        }

        /*
         | 将根id和分类深度写回去
         | 使用save方法
         */
        $result->root_id = $rootId;
        $result->deep = $deep;
        $result->path = $path;
        if (! $result->save()) {
            throw new CommodityCateException("商品分类没有添加成功", ExceptionCode::CREATED_FAILURE);
        }

        return $result;
    }
1063890
public function create(array $data)
  {
    $VoucherType = new VoucherType();
    $VoucherType->setConnection($this->databaseConnectionName);
    $VoucherType->fill($data)->save();

    return $VoucherType;
  }
1367440
protected function buildModel(array $data = array()){
        $Model = NULL;
        if (isset($this->model)){
            $Model = new $this->model();
            $Model->setBaseUrl($this->getBaseUrl());
            if ($this->getAuth() !== NULL) {
                $Model->setAuth($this->getAuth());
            }
            if (!empty($data)){
                foreach($data as $key => $value){
                    $Model->set($key,$value);
                }
            }
        }
        return $Model;
    }
650973
protected function getOrCreateObject(?array $data = null)
    {
        if ($data === null) {
            return null;
        }

        return $this->objectManager->getOrCreateObject(
            $this->getClassName(),
            $data
        );
    }
190182
public static function fromArray(array $data): self
    {
        $fixed_list = new static();

        $fixed_list->decorated = SplFixedArray::fromArray($data, false);

        return $fixed_list;
    }
314559
public function createModel(array $data)
    {
        $tag = new TagGroup();
        if (array_key_exists('id', $data)) {
            $tag->id = $data['id'];
        }

        $tag->name = $data['name'];
        $tag->handle = $data['handle'];

        if (array_key_exists('fieldLayout', $data)) {
            $requiredFields = array();
            if (array_key_exists('requiredFields', $data)) {
                foreach ($data['requiredFields'] as $handle) {
                    $field = Craft::$app->fields->getFieldByHandle($handle);
                    if ($field) {
                        $requiredFields[] = $field->id;
                    }
                }
            }

            $layout = array();
            foreach ($data['fieldLayout'] as $key => $fields) {
                $fieldIds = array();
                foreach ($fields as $field) {
                    $existingField = Craft::$app->fields->getFieldByHandle($field);
                    if ($existingField) {
                        $fieldIds[] = $existingField->id;
                    } else {
                        $this->addError('error', 'Missing field: ' . $field . ' can not add to field layout for Tag: ' . $tag->handle);
                    }
                }
                $layout[$key] = $fieldIds;
            }


            $fieldLayout = Craft::$app->fields->assembleLayout($layout, $requiredFields);
            $fieldLayout->type = Tag::class;
            $tag->fieldLayout = $fieldLayout;
        }

        return $tag;
    }
623476
public function setRawData(array $data)
    {
        $this->data = $data + $this->data;

        if ($data) {
            $this->loaded = true;
            $this->setDataSource('*', 'db');
        }

        return $this;
    }
195079
public function optimize (stdClass $data)
    {
        $data->modelDirectory = str_replace ('/http/controllers', '/models', $data->controllerDestination);
        $data->modelNamespace = str_replace ('\\http\\controllers', '\\models', $data->controllerNamespace);

        foreach ($data->database as $dbItem) {
            $dbItem->columns       = $this->getTableColumns ($dbItem->tableName);
            $dbItem->modelLocation = $data->modelDirectory . '/' . $dbItem->modelName . '.php';

            if (isset($dbItem->default) && $dbItem->default)
                if (isset($dbItem->multiLanguage)) {
                    $dbItem->multiLanguage->columns       = $this->getTableColumns ($dbItem->multiLanguage->tableName);
                    $dbItem->multiLanguage->modelName     = $dbItem->modelName . 'Translations';
                    $dbItem->multiLanguage->modelLocation = $data->modelDirectory . '/' . $dbItem->modelName . 'Translations.php';
                }
        }

        //TODO get default model, there can be only one
        $data->mainModel = $data->database[0];

        return $data;
    }
560285
public static function fromData(array $data)
    {
        $policies = [];
        foreach (isset($data['schedule']) ? $data['schedule'] : [] as $policyData) {
            $policies[] = new Policy($policyData['interval'], $policyData['count']);
        }

        return new static($policies, isset($data['manual_count']) ? $data['manual_count'] : 1);
    }
234781
public static function deserializeObject(array $data)
    {
        $result = new static($data['resourceType'], isset($data['created']) ? Helper::string2dateTime($data['created']) : null);
        if (isset($data['lastModified'])) {
            $result->lastModified = Helper::string2dateTime($data['lastModified']);
        }
        if (isset($data['location'])) {
            $result->location = $data['location'];
        }
        if (isset($data['version'])) {
            $result->version = $data['version'];
        }

        return $result;
    }
646519
public function create(array $data)
    {
        $response = $this->ontraport->post(
            $this->getNamespace(), $this->toArray($data)
        );

        return $this->ontraport->item($this, $response);
    }
118236
public function setData(array $data)
    {
        $data = $this->setIdFromData($data);

        parent::setData($data);
        return $this;
    }
1063712
protected function objectToArray(stdClass $data = null)
    {
        if (null !== $data) {
            $data = (array) $data;
            foreach ($data as $key => $value) {
                if ($value instanceof stdClass) {
                    $data[$key] = $this->objectToArray($value);
                }
            }
        }

        return $data;
    }
69081
public static function createFromArray(array $data)
    {
        $self = new self();

        foreach ($data as $translation) {
            $self->addTranslation(Translation::createFromArray($translation));
        }

        return $self;
    }
671879
public static function add(array $data)
    {
        $model = Yii::createObject(static::className());
        $model->setAttributes($data);
        return $model->save() ?: $model;
    }
1216289
public function fromArray($data)
    {
        if (empty($data)) {
            return $this;
        }
        if (isset($data['type']) && $data['type']) {
            $this->setType($data['type']);
        }
        if (isset($data[$this->getType()]) && $data[$this->getType()]) {
            $this->setValue($data[$this->getType()]);
        }
        return $this;
    }
451874
public function with($data)
    {
        if (\is_array($data)) {
            $data = new Fluent($data);
        }

        $this->data = $data;

        return $this;
    }