Skip to content

Commit 86382b8

Browse files
dgerikeMulkave
authored andcommitted
add missing getForeignKeyName method (#286)
1 parent 261f4c2 commit 86382b8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Eloquent/Relations/BelongsTo.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,27 @@ public function getEdge(EloquentModel $model = null, $attributes = array())
107107
$unique = true;
108108
return new EdgeIn($this->query, $this->parent, $model, $this->foreignKey, $attributes, $unique);
109109
}
110+
111+
/**
112+
* Get the plain foreign key.
113+
*
114+
* @return string
115+
*/
116+
public function getForeignKeyName()
117+
{
118+
$segments = explode('.', $this->getQualifiedForeignKeyName());
119+
120+
return end($segments);
121+
}
122+
123+
/**
124+
* Get the foreign key for the relationship.
125+
*
126+
* @return string
127+
*/
128+
public function getQualifiedForeignKeyName()
129+
{
130+
return $this->foreignKey;
131+
}
110132

111133
}

0 commit comments

Comments
 (0)