This commit is contained in:
2020-09-11 18:04:46 +08:00
parent 4dc451fe7a
commit 42623eadc7
+5 -1
View File
@@ -49,9 +49,13 @@ class ActiveQuery extends Component
* Comply constructor. * Comply constructor.
* @param $model * @param $model
* @param array $config * @param array $config
* @throws
*/ */
public function __construct($model, $config = []) public function __construct($model, $config = [])
{ {
if (!is_object($model)) {
$model = Snowflake::createObject($model);
}
$this->modelClass = $model; $this->modelClass = $model;
parent::__construct($config); parent::__construct($config);
} }
@@ -139,7 +143,7 @@ class ActiveQuery extends Component
if (empty($data)) { if (empty($data)) {
return NULL; return NULL;
} }
$newModel = Snowflake::createObject($this->modelClass); $newModel = $this->modelClass;
$newModel = $this->populate($newModel, $data); $newModel = $this->populate($newModel, $data);
if ($this->asArray) { if ($this->asArray) {
return $newModel->toArray(); return $newModel->toArray();