diff --git a/library/think/model/relation/HasManyThrough.php b/library/think/model/relation/HasManyThrough.php index 7d0d5124..1573fc65 100644 --- a/library/think/model/relation/HasManyThrough.php +++ b/library/think/model/relation/HasManyThrough.php @@ -130,10 +130,9 @@ class HasManyThrough extends Relation { if (empty($this->baseQuery) && $this->parent->getData()) { $through = $this->through; - $model = $this->model; - $alias = Loader::parseName(basename(str_replace('\\', '/', $model))); + $alias = Loader::parseName(basename(str_replace('\\', '/', $this->model))); $throughTable = $through::getTable(); - $pk = (new $this->model)->getPk(); + $pk = (new $through)->getPk(); $throughKey = $this->throughKey; $modelTable = $this->parent->getTable(); $this->query->field($alias . '.*')->alias($alias)