mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
Model类添加getRelation方法用于获取关联属性
This commit is contained in:
@@ -354,6 +354,23 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
return $this;
|
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
|
* @access public
|
||||||
|
|||||||
Reference in New Issue
Block a user