diff --git a/src/Eloquent/Relations/Traits/HasExistenceQueries.php b/src/Eloquent/Relations/Traits/HasExistenceQueries.php index 7f16288..c46b072 100644 --- a/src/Eloquent/Relations/Traits/HasExistenceQueries.php +++ b/src/Eloquent/Relations/Traits/HasExistenceQueries.php @@ -51,11 +51,11 @@ public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder $query->getModel()->setTable($hash); - /** @var string $from */ - $from = $query->getQuery()->from; + /** @var string $parentFrom */ + $parentFrom = $parentQuery->getQuery()->from; $query->select($columns)->whereColumn( - "$from.$this->localKey", + "$parentFrom.$this->localKey", '=', $this->getQualifiedFirstKeyName() );