mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 08:02:48 +08:00
改进Model类的关联属性判断
This commit is contained in:
@@ -56,6 +56,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
protected $pk;
|
protected $pk;
|
||||||
// 数据表字段信息 留空则自动获取
|
// 数据表字段信息 留空则自动获取
|
||||||
protected $field = [];
|
protected $field = [];
|
||||||
|
// 关联属性
|
||||||
|
protected $relationAttr = [];
|
||||||
// 只读字段
|
// 只读字段
|
||||||
protected $readonly = [];
|
protected $readonly = [];
|
||||||
// 显示属性
|
// 显示属性
|
||||||
@@ -1083,11 +1085,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
{
|
{
|
||||||
$relation = Loader::parseName($attr, 1, false);
|
$relation = Loader::parseName($attr, 1, false);
|
||||||
|
|
||||||
if (method_exists($this, $relation)) {
|
if (!empty($this->relationAttr) && in_array($attr, $this->relationAttr)) {
|
||||||
|
return $relation;
|
||||||
|
} elseif (method_exists($this, $relation)) {
|
||||||
return $relation;
|
return $relation;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user