Skip to content

Commit 459d721

Browse files
authored
Merge pull request #19 from eafarooqi/develop
2 parents d033806 + e42909f commit 459d721

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Traits/EntityTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public function __isset(string $key): bool
7676
*/
7777
public function __call(string $name, array $arguments)
7878
{
79+
$this->_verifyRelatable();
80+
7981
$verbs = ['has', 'set', 'add', 'remove'];
8082

8183
// Parse the name to check for supported relation verbs
@@ -153,6 +155,12 @@ public function __call(string $name, array $arguments)
153155
*/
154156
public function relations(string $tableName, $keysOnly = false)
155157
{
158+
// If entity primary key is not set then finish
159+
if (! isset($this->attributes[$this->primaryKey]))
160+
{
161+
return null;
162+
}
163+
156164
// Use BaseTrait to get related items
157165
$items = $this->_getRelations($tableName);
158166

0 commit comments

Comments
 (0)