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 eed876e commit 82cab1eCopy full SHA for 82cab1e
src/Jenssegers/Mongodb/Model.php
@@ -51,12 +51,16 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
51
*/
52
public function getIdAttribute($value)
53
{
54
- if (!$value && array_key_exists('_id', $this->attributes)) {
+ // If we don't have a value for 'id', we will use the Mongo '_id' value.
55
+ // This allows us to work with models in a more sql-like way.
56
+ if ( ! $value and array_key_exists('_id', $this->attributes))
57
+ {
58
$value = $this->attributes['_id'];
59
}
60
- // Return _id as string
- if ($value instanceof MongoId) {
61
+ // Convert MongoId's to string.
62
+ if ($value instanceof MongoId)
63
64
return (string) $value;
65
66
0 commit comments