diff --git a/src/EloquentBuilderTrait.php b/src/EloquentBuilderTrait.php index c54e631..34c8f7f 100644 --- a/src/EloquentBuilderTrait.php +++ b/src/EloquentBuilderTrait.php @@ -279,9 +279,9 @@ private function joinRelatedModelIfExists(Builder $queryBuilder, $key) if ($relation instanceof BelongsTo) { $queryBuilder->join( $relation->getRelated()->getTable(), - $model->getTable().'.'.$relation->getQualifiedForeignKeyName(), + $relation->getQualifiedForeignKey(), '=', - $relation->getRelated()->getTable().'.'.$relation->getOwnerKey(), + $relation->getQualifiedOwnerKeyName(), $type ); } elseif ($relation instanceof BelongsToMany) {