Skip to content

Commit

Permalink
Fix the broken tests for older laravel versions (#63)
Browse files Browse the repository at this point in the history
* Sort the models to get the same results for laravel 5.6 as for the newer versions

* Make the relations backward compatible with < laravel 5.8
  • Loading branch information
daniel-werner authored and jafar690 committed Oct 14, 2019
1 parent 0268113 commit d027d5e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ModelFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getModelsInDirectory(string $directory): Collection
return !empty($className)
&& is_subclass_of($className, EloquentModel::class)
&& ! (new ReflectionClass($className))->isAbstract();
})->diff($ignoreModels);
})->diff($ignoreModels)->sort();
}

protected function getFullyQualifiedClassNameFromFile(string $path): string
Expand Down
2 changes: 1 addition & 1 deletion src/RelationFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function getRelationshipFromMethodAndModel(ReflectionMethod $method, s

if ($return instanceof BelongsTo) {
$foreignKey = $this->getParentKey($return->getQualifiedOwnerKeyName());
$localKey = $return->getForeignKeyName();
$localKey = method_exists($return, 'getForeignKeyName') ? $return->getForeignKeyName() : $return->getForeignKey();
}

return [
Expand Down

0 comments on commit d027d5e

Please sign in to comment.