diff --git a/src/Parser.php b/src/Parser.php index ee54138..d9b82b5 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -391,7 +391,10 @@ protected function parseWith($withParam) $firstKey = $relation->getQualifiedParentKeyName(); $secondKey = $relation->getRelated()->getQualifiedKeyName(); } else if ($relationType === 'HasManyThrough') { - if (method_exists($relation, 'getExistenceCompareKey')) { + if (method_exists($relation, 'getQualifiedLocalKeyName')) { + $firstKey = $relation->getQualifiedLocalKeyName(); + } else if (method_exists($relation, 'getExistenceCompareKey')) { + // compatibility for laravel 5.4 $firstKey = $relation->getExistenceCompareKey(); } else { // compatibility for laravel < 5.4