Skip to content

Commit 3274f22

Browse files
committed
改进
1 parent d05e89e commit 3274f22

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/model/Virtual.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
abstract class Virtual extends Model
2525
{
2626
/**
27-
* 写入数据.
27+
* 创建数据.
2828
*
2929
* @param array|object $data 数据
3030
* @param array $allowField 允许字段
@@ -37,10 +37,9 @@ public static function create(array | object $data, array $allowField = [], bool
3737

3838
if (!empty($data)) {
3939
// 初始化模型数据
40-
$model->initializeData($data, true);
40+
$model->data($data);
4141
}
42-
43-
return $model->fetchModel($model);
42+
return $model;
4443
}
4544

4645
/**
@@ -61,7 +60,7 @@ public function getQuery()
6160
*/
6261
protected function getFields(?string $field = null)
6362
{
64-
$schema = $this->getOption('schema', []);
63+
$schema = array_merge($this->getOption('schema', []), $this->getOption('type', []));
6564

6665
if ($field) {
6766
return $schema[$field] ?? null;

src/model/concern/Attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trait Attribute
4040
*
4141
* @return void
4242
*/
43-
protected function initializeData(array | object $data, bool $fromSave = false)
43+
private function initializeData(array | object $data, bool $fromSave = false)
4444
{
4545
// 分析数据
4646
$data = $this->parseData($data);

0 commit comments

Comments
 (0)