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');