Skip to content

Commit

Permalink
Fix backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammedkamel committed Nov 27, 2023
1 parent cb51087 commit 605941d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Relations/BelongsToThrough.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function getLocalKeyName(Model $model = null): string
return $this->localKeyLookup[$table];
}

return 'id';
return $model->getKeyName();
}

/**
Expand Down Expand Up @@ -359,7 +359,9 @@ public function getFirstForeignKeyName()
*/
public function getQualifiedFirstLocalKeyName()
{
return end($this->throughParents)->qualifyColumn($this->getLocalKeyName(end($this->throughParents)));
$lastThroughParent = end($this->throughParents);

return $lastThroughParent->qualifyColumn($this->getLocalKeyName($lastThroughParent));
}

/**
Expand Down

0 comments on commit 605941d

Please sign in to comment.