diff --git a/src/Drivers/EloquentEntitySet.php b/src/Drivers/EloquentEntitySet.php index 6fc4e5f53..fe1739a5b 100644 --- a/src/Drivers/EloquentEntitySet.php +++ b/src/Drivers/EloquentEntitySet.php @@ -514,6 +514,13 @@ public function discoverRelationship( /** @var Relation $relation */ $relation = $model->$method(); + if (!$relation instanceof Relation) { + throw new ConfigurationException( + 'invalid_relationship', + 'The method could not return a valid relationship' + ); + } + $relatedModel = get_class($relation->getRelated()); $right = Lodata::getResources()->sliceByClass(self::class)->find(function ($set) use ($relatedModel) {