Skip to content

Commit d027d5e

Browse files
daniel-wernerjafar690
authored andcommitted
Fix the broken tests for older laravel versions (#63)
* 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
1 parent 0268113 commit d027d5e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/ModelFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getModelsInDirectory(string $directory): Collection
4040
return !empty($className)
4141
&& is_subclass_of($className, EloquentModel::class)
4242
&& ! (new ReflectionClass($className))->isAbstract();
43-
})->diff($ignoreModels);
43+
})->diff($ignoreModels)->sort();
4444
}
4545

4646
protected function getFullyQualifiedClassNameFromFile(string $path): string

src/RelationFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function getRelationshipFromMethodAndModel(ReflectionMethod $method, s
8080

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

8686
return [

0 commit comments

Comments
 (0)