diff --git a/library/think/Model.php b/library/think/Model.php index 3b24b135..8553fec6 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -354,6 +354,23 @@ abstract class Model implements \JsonSerializable, \ArrayAccess return $this; } + /** + * 获取当前模型的关联模型数据 + * @access public + * @param string $name 关联方法名 + * @return mixed + */ + public function getRelation($name = null) + { + if (is_null($name)) { + return $this->relation; + } elseif (array_key_exists($name, $this->relation)) { + return $this->relation[$name]; + } else { + return; + } + } + /** * 设置关联数据对象值 * @access public