Skip to content

Commit

Permalink
add missing getForeignKeyName method (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgerike authored and Mulkave committed Jun 5, 2018
1 parent 261f4c2 commit 86382b8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,27 @@ public function getEdge(EloquentModel $model = null, $attributes = array())
$unique = true;
return new EdgeIn($this->query, $this->parent, $model, $this->foreignKey, $attributes, $unique);
}

/**
* Get the plain foreign key.
*
* @return string
*/
public function getForeignKeyName()
{
$segments = explode('.', $this->getQualifiedForeignKeyName());

return end($segments);
}

/**
* Get the foreign key for the relationship.
*
* @return string
*/
public function getQualifiedForeignKeyName()
{
return $this->foreignKey;
}

}

0 comments on commit 86382b8

Please sign in to comment.