修改器和获取器方法支持第三个参数关联数据

This commit is contained in:
thinkphp
2017-07-04 23:38:17 +08:00
parent 0cfb72c6b5
commit 5c733a7743

View File

@@ -353,7 +353,7 @@ 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));
$value = $this->$method($value, array_merge($this->data, $data), $this->relation);
} elseif (isset($this->type[$name])) {
// 类型转换
$value = $this->writeTransform($value, $this->type[$name]);
@@ -532,7 +532,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 检测属性获取器
$method = 'get' . Loader::parseName($name, 1) . 'Attr';
if (method_exists($this, $method)) {
$value = $this->$method($value, $this->data);
$value = $this->$method($value, $this->data, $this->relation);
} elseif (isset($this->type[$name])) {
// 类型转换
$value = $this->readTransform($value, $this->type[$name]);