mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
改进关联属性的判断
This commit is contained in:
@@ -517,7 +517,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
} elseif ($notFound) {
|
} elseif ($notFound) {
|
||||||
$relation = $this->isRelationAttr($name);
|
$relation = $this->isRelationAttr($name);
|
||||||
$method = Loader::parseName($name, 1, false);
|
|
||||||
if ($relation) {
|
if ($relation) {
|
||||||
$modelRelation = $this->$relation();
|
$modelRelation = $this->$relation();
|
||||||
// 不存在该字段 获取关联数据
|
// 不存在该字段 获取关联数据
|
||||||
@@ -537,7 +536,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
* @param Relation $modelRelation 模型关联对象
|
* @param Relation $modelRelation 模型关联对象
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function getRelationData($modelRelation)
|
protected function getRelationData(Relation $modelRelation)
|
||||||
{
|
{
|
||||||
if ($this->parent && get_class($this->parent) == $modelRelation->getModel()) {
|
if ($this->parent && get_class($this->parent) == $modelRelation->getModel()) {
|
||||||
$value = $this->parent;
|
$value = $this->parent;
|
||||||
@@ -1084,10 +1083,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
$relation = Loader::parseName($attr, 1, false);
|
$relation = Loader::parseName($attr, 1, false);
|
||||||
|
|
||||||
if (method_exists($this, $relation)) {
|
if (method_exists($this, $relation)) {
|
||||||
$reflect = new \ReflectionMethod($this, $relation);
|
return $relation;
|
||||||
if (0 == $reflect->getNumberOfParameters() && $this->$relation() instanceof Relation) {
|
|
||||||
return $relation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user