We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c22670a commit 1722dafCopy full SHA for 1722daf
src/Jenssegers/Mongodb/Model.php
@@ -49,11 +49,18 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
49
*/
50
public function getIdAttribute($value)
51
{
52
- if ($value) return (string) $value;
+ if ($value) {
53
+ // Return _id as string
54
+ if ($value instanceof MongoId) {
55
+ return (string) $value;
56
+ }
57
+
58
+ return $value;
59
60
- // Return _id as string
61
if (array_key_exists('_id', $this->attributes))
62
63
64
if ($this->attributes['_id'] instanceof MongoId) {
65
return (string) $this->attributes['_id'];
66
}
0 commit comments