修正MorphTo关联

This commit is contained in:
thinkphp
2018-01-24 19:13:28 +08:00
parent 618fb51788
commit 09f031b371

View File

@@ -43,6 +43,18 @@ class MorphTo extends Relation
$this->relation = $relation;
}
/**
* 获取当前的关联模型类的实例
* @access public
* @return Model
*/
public function getModel()
{
$morphKey = $this->morphKey;
$model = $this->parseModel($this->parent->$morphType);
return (new $model)->db()->getModel();
}
/**
* 延迟获取关联数据
* @param string $subRelation 子关联名