改进关联的属性绑定

This commit is contained in:
thinkphp
2017-07-20 17:52:11 +08:00
parent 8a52dd232f
commit 8ff20f98d0
3 changed files with 12 additions and 11 deletions

View File

@@ -276,7 +276,7 @@ abstract class OneToOne extends Relation
if (isset($result->$key)) {
throw new Exception('bind attr has exists:' . $key);
} else {
$result->setAttr($key, $model->$attr);
$result->setAttr($key, $model ? $model->$attr : null);
}
}
}