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