mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
关联预载入方法调整 取消class参数 关联的数据集查询根据模型的数据集返回类型设定
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace think\model\relation;
|
||||
|
||||
use think\Exception;
|
||||
use think\Loader;
|
||||
use think\Model;
|
||||
use think\model\Relation;
|
||||
@@ -95,10 +96,9 @@ class MorphTo extends Relation
|
||||
* @param string $relation 当前关联名
|
||||
* @param string $subRelation 子关联名
|
||||
* @param \Closure $closure 闭包
|
||||
* @param string $class 数据集对象名 为空表示数组
|
||||
* @return void
|
||||
*/
|
||||
public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure, $class)
|
||||
public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure)
|
||||
{
|
||||
$morphKey = $this->morphKey;
|
||||
$morphType = $this->morphType;
|
||||
@@ -125,10 +125,12 @@ class MorphTo extends Relation
|
||||
}
|
||||
foreach ($resultSet as $result) {
|
||||
if ($key == $result->$morphType) {
|
||||
// 关联模型
|
||||
if (!isset($data[$result->$morphKey])) {
|
||||
$data[$result->$morphKey] = [];
|
||||
throw new Exception('relation data not exists :' . $this->model);
|
||||
} else {
|
||||
$result->setAttr($attr, $data[$result->$morphKey]);
|
||||
}
|
||||
$result->setAttr($attr, $this->resultSetBuild($data[$result->$morphKey], $class));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,10 +144,9 @@ class MorphTo extends Relation
|
||||
* @param string $relation 当前关联名
|
||||
* @param string $subRelation 子关联名
|
||||
* @param \Closure $closure 闭包
|
||||
* @param string $class 数据集对象名 为空表示数组
|
||||
* @return void
|
||||
*/
|
||||
public function eagerlyResult(&$result, $relation, $subRelation, $closure, $class)
|
||||
public function eagerlyResult(&$result, $relation, $subRelation, $closure)
|
||||
{
|
||||
$morphKey = $this->morphKey;
|
||||
$morphType = $this->morphType;
|
||||
|
||||
Reference in New Issue
Block a user