Skip to content

Commit

Permalink
Merge pull request #44 from OliverBeckwith/feature/parent-model-classes
Browse files Browse the repository at this point in the history
Allow relations from intermediate parent classes
  • Loading branch information
Luukdewaaier authored Mar 6, 2024
2 parents 5f06e60 + ee67301 commit 44e8357
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Support/Generators/RelationPropertyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ public function getPropertyDefinition(Model $model): array
$withProperty->setAccessible(true);
$withFields = $withProperty->getValue($model);

$permittedClasses = [get_class($model)];
foreach(class_parents($model) as $parent) {
if ($parent === Model::class) {
break;
}
$permittedClasses[] = $parent;
}

foreach ($reflectionClass->getMethods() as $method) {
if ($method->class === get_class($model)) {
if (in_array($method->class, $permittedClasses)) {
// FIXME: if there only is docblock available, make sure it works for unqualified names aswell
$returnType = $this->getReturnType($method);

Expand Down

0 comments on commit 44e8357

Please sign in to comment.