Commit 1722daf4 authored by Kévin Bargoin's avatar Kévin Bargoin

Allows an _id attribute of another type than string

parent c22670a5
...@@ -49,11 +49,18 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -49,11 +49,18 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
*/ */
public function getIdAttribute($value) public function getIdAttribute($value)
{ {
if ($value) return (string) $value; if ($value) {
// Return _id as string
if ($value instanceof MongoId) {
return (string) $value;
}
return $value;
}
// Return _id as string
if (array_key_exists('_id', $this->attributes)) if (array_key_exists('_id', $this->attributes))
{ {
// Return _id as string
if ($this->attributes['_id'] instanceof MongoId) { if ($this->attributes['_id'] instanceof MongoId) {
return (string) $this->attributes['_id']; return (string) $this->attributes['_id'];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment