jarektkaczyk / eloquence-base

base for the Eloquence extensions + Searchable
https://softonsofa.com
MIT License
77 stars 69 forks source link

Fix the way join keys are set for a relation that's instance of HasManyThrough #22

Closed crlcu closed 4 years ago

crlcu commented 4 years ago

A user can specify a different secondLocalKey. The current implementation is always looking for the getQualifiedKeyName of the parent which assumes is the value returned by getKeyName

protected function getJoinKeys(Relation $relation)
{
    ...

    if ($relation instanceof HasManyThrough) {
        $fk = $relation->getQualifiedFarKeyName();

        return [$fk, $relation->getParent()->getQualifiedKeyName()];
    }
}

In this new version, it's going to look at the $relation->getQualifiedParentKeyName() which is retrieved based on the value that was set for secondLocalKey when the relation was defined.

crlcu commented 4 years ago

Any idea when/if this will be merged?