From c171243c2ef67a98b077051ad90b7ccc4f4a4b34 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Jan 2022 14:22:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=BF=9C=E7=A8=8B=E4=B8=80?= =?UTF-8?q?=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/relation/HasManyThrough.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/model/relation/HasManyThrough.php b/src/model/relation/HasManyThrough.php index d4b7d912..fc620264 100644 --- a/src/model/relation/HasManyThrough.php +++ b/src/model/relation/HasManyThrough.php @@ -258,8 +258,14 @@ protected function eagerlyWhere(array $where, string $key, array $subRelation = $closure($this->getClosureType($closure)); } + $throughKey = $this->throughKey; + + if ($this->baseQuery) { + $throughKey = Str::snake(class_basename($this->model)) . "." . $this->throughKey; + } + $list = $this->query - ->where($this->throughKey, 'in', $keys) + ->where($throughKey, 'in', $keys) ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) ->select();