改进Model类的setAttr方法

This commit is contained in:
thinkphp
2017-04-27 11:18:14 +08:00
parent bfcdd5ce6a
commit e9d45eb570

View File

@@ -343,14 +343,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$method = 'set' . Loader::parseName($name, 1) . 'Attr';
if (method_exists($this, $method)) {
$value = $this->$method($value, array_merge($this->data, $data));
}
if ($this->isRelationAttr($name)) {
$isRelationData = true;
} elseif (isset($this->type[$name])) {
// 类型转换
$value = $this->writeTransform($value, $this->type[$name]);
}
if ($this->isRelationAttr($name)) {
$isRelationData = true;
}
}
// 设置数据对象属性