From 6ebaf7e44e591c80468e4bb3ce7cc74d27920919 Mon Sep 17 00:00:00 2001 From: yaobiao131 <28655758+yaobiao131@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:06:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9C=E7=A8=8B=E4=B8=80?= =?UTF-8?q?=E5=AF=B9=E5=A4=9A=E6=8C=87=E5=AE=9A=E5=AD=97=E6=AE=B5=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=88=AB=E5=90=8D=E6=9C=AA=E6=AD=A3=E7=A1=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/relation/HasManyThrough.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/model/relation/HasManyThrough.php b/src/model/relation/HasManyThrough.php index 6d8349d9..ad973e0b 100644 --- a/src/model/relation/HasManyThrough.php +++ b/src/model/relation/HasManyThrough.php @@ -270,7 +270,9 @@ protected function eagerlyWhere(array $where, string $key, array $subRelation = $throughKey = $this->throughKey; if ($this->baseQuery) { - $throughKey = Str::snake(class_basename($this->model)) . '.' . $this->throughKey; + $alias = Str::snake(class_basename($this->model)); + $throughKey = $alias . '.' . $this->throughKey; + $this->query->alias($alias); } $withLimit = $this->query->getOptions('limit');