Skip to content

Commit

Permalink
Tweaking id accessor for #108
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Jan 13, 2014
1 parent 89e059b commit b625036
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Jenssegers/Mongodb/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public function getIdAttribute($value)
// If there is an actual id attribute, then return that.
if ($value) return $value;

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

/**
Expand Down

0 comments on commit b625036

Please sign in to comment.