mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
修正多对多预载入查询
This commit is contained in:
@@ -197,7 +197,7 @@ class Relation
|
||||
if (!empty($range)) {
|
||||
// 查询关联数据
|
||||
$data = $this->eagerlyManyToMany($model, [
|
||||
'pivot.' . $foreignKey => [
|
||||
'pivot.' . $localKey => [
|
||||
'in',
|
||||
$range,
|
||||
],
|
||||
@@ -277,7 +277,7 @@ class Relation
|
||||
if (isset($result->$pk)) {
|
||||
$pk = $result->$pk;
|
||||
// 查询管理数据
|
||||
$data = $this->eagerlyManyToMany($model, ['pivot.' . $foreignKey => $pk], $relation, $subRelation);
|
||||
$data = $this->eagerlyManyToMany($model, ['pivot.' . $localKey => $pk], $relation, $subRelation);
|
||||
|
||||
// 关联数据封装
|
||||
if (!isset($data[$pk])) {
|
||||
@@ -374,7 +374,7 @@ class Relation
|
||||
}
|
||||
}
|
||||
$set->pivot = new Pivot($pivot, $this->middle);
|
||||
$data[$set->$foreignKey][] = $set;
|
||||
$data[$pivot[$localKey]][] = $set;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user