Skip to content

Commit

Permalink
Fix - getRelated() on null for relationship discovery (#790)
Browse files Browse the repository at this point in the history
Addresses an issue by introducing an additional instanceof check for the `$relation` to see if it's a valid relationship. If not, bail early.
  • Loading branch information
coderkoala authored Feb 7, 2024
1 parent 1c3b45a commit 53c8c3f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Drivers/EloquentEntitySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 53c8c3f

Please sign in to comment.