Skip to content

Commit 2f3902d

Browse files
authored
Merge pull request #1 from eafarooqi/eafarooqi-patch-1
Empty Object Return data from related tables
2 parents d033806 + 90e023c commit 2f3902d

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)