Skip to content

Commit

Permalink
Fixes get relation result
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Sep 20, 2023
1 parent 2cd447d commit 43c1d39
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Database/Barry/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,11 @@ public function __get(string $name): mixed
$attribute_exists = isset($this->attributes[$name]);

if (!$attribute_exists && method_exists($this, $name)) {
return $this->$name()->getResults();
$result = $this->$name();
if ($result instanceof Relation) {
return $result->getResults();
}
return $result;
}

if (!$attribute_exists) {
Expand Down

0 comments on commit 43c1d39

Please sign in to comment.