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