mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-05 22:52:49 +08:00
一对一关联定义支持绑定关联模型属性到当前模型 在定义关联的时候使用bind方法
This commit is contained in:
@@ -111,7 +111,13 @@ class HasOne extends OneToOne
|
||||
if (!isset($data[$result->$localKey])) {
|
||||
$data[$result->$localKey] = [];
|
||||
}
|
||||
$result->setAttr($relation, $this->resultSetBuild($data[$result->$localKey], $class));
|
||||
$relationModel = $this->resultSetBuild($data[$result->$localKey], $class);
|
||||
if (!empty($this->bindAttr)) {
|
||||
// 绑定关联属性
|
||||
$this->bindAttr($relationModel, $result, $this->bindAttr);
|
||||
}
|
||||
// 设置关联属性
|
||||
$result->setAttr($relation, $relationModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +141,12 @@ class HasOne extends OneToOne
|
||||
if (!isset($data[$result->$localKey])) {
|
||||
$data[$result->$localKey] = [];
|
||||
}
|
||||
$result->setAttr($relation, $this->resultSetBuild($data[$result->$localKey], $class));
|
||||
$relationModel = $this->resultSetBuild($data[$result->$localKey], $class);
|
||||
if (!empty($this->bindAttr)) {
|
||||
// 绑定关联属性
|
||||
$this->bindAttr($relationModel, $result, $this->bindAttr);
|
||||
}
|
||||
$result->setAttr($relation, $relationModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user