Skip to content

Commit e18cc36

Browse files
Fix for getForeignKey() exception on Laravel > 5.8
Fix for exception: `Exception: Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::getForeignKey()` on Laravel >= 5.8 while still maintaining backwards compatibility with Laravel < 5.8
1 parent a4111f0 commit e18cc36

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Console/GenerateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ protected function getPropertiesFromMethods($model)
277277
if ($relationObj instanceof Relation) {
278278
$relatedModel = '\\' . get_class($relationObj->getRelated());
279279
$relatedObj = new $relatedModel;
280-
$property = property_exists($relationObj, 'getForeignKeyName')
280+
$property = method_exists($relationObj, 'getForeignKeyName')
281281
? $relationObj->getForeignKeyName()
282282
: $relationObj->getForeignKey();
283283
$this->setProperty($property, 'factory(' . get_class($relationObj->getRelated()) . '::class)->create()->' . $relatedObj->getKeyName());

0 commit comments

Comments
 (0)