Skip to content

Commit 90e023c

Browse files
authored
Empty Object Return data from related tables
1 parent d033806 commit 90e023c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/Traits/EntityTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ public function __call(string $name, array $arguments)
153153
*/
154154
public function relations(string $tableName, $keysOnly = false)
155155
{
156+
// If entity primary key is not set then finish
157+
if (!isset($this->attributes[$this->primaryKey]))
158+
{
159+
return null;
160+
}
161+
156162
// Use BaseTrait to get related items
157163
$items = $this->_getRelations($tableName);
158164

0 commit comments

Comments
 (0)