改进关联模型

This commit is contained in:
thinkphp
2017-04-01 16:13:44 +08:00
parent 2ebf07ba16
commit d3be47e269
7 changed files with 39 additions and 13 deletions

View File

@@ -56,8 +56,10 @@ class MorphTo extends Relation
// 多态模型
$model = $this->parseModel($this->parent->$morphType);
// 主键数据
$pk = $this->parent->$morphKey;
return (new $model)->relation($subRelation)->find($pk);
$pk = $this->parent->$morphKey;
$relationModel = (new $model)->relation($subRelation)->find($pk);
$relationModel->setParent(clone $this->parent);
return $relationModel;
}
/**