Skip to content

Commit

Permalink
一对一关联查询绑定属性调整
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jan 17, 2022
1 parent 6f5c7f6 commit 2eb8d02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/model/relation/BelongsTo.php
Expand Up @@ -236,12 +236,11 @@ protected function eagerlySet(array &$resultSet, string $relation, array $subRel
$relationModel->exists(true);
}

// 设置关联属性
$result->setRelation($relation, $relationModel);
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
} else {
// 设置关联属性
$result->setRelation($relation, $relationModel);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/model/relation/HasOne.php
Expand Up @@ -234,13 +234,12 @@ protected function eagerlySet(array &$resultSet, string $relation, array $subRel
$relationModel->setParent(clone $result);
$relationModel->exists(true);
}
// 设置关联属性
$result->setRelation($relation, $relationModel);

if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
} else {
// 设置关联属性
$result->setRelation($relation, $relationModel);
}
}
}
Expand Down

1 comment on commit 2eb8d02

@mrdznet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里都这么改了吗?

以后如果不想显示关联属性,只显示绑定该如何操作?

Please sign in to comment.