Skip to content

Commit b625036

Browse files
committed
Tweaking id accessor for #108
1 parent 89e059b commit b625036

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Jenssegers/Mongodb/Model.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public function getIdAttribute($value)
4848
// If there is an actual id attribute, then return that.
4949
if ($value) return $value;
5050

51-
return $this->attributes[$this->getKeyName()];
51+
// Return primary key value if present
52+
if (array_key_exists($this->getKeyName(), $this->attributes)) return $this->attributes[$this->getKeyName()];
5253
}
5354

5455
/**

0 commit comments

Comments
 (0)