Commit cb59979a authored by Kévin Bargoin's avatar Kévin Bargoin

Refactor _id attribute getter

parent 1722daf4
...@@ -49,24 +49,16 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -49,24 +49,16 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
*/ */
public function getIdAttribute($value) public function getIdAttribute($value)
{ {
if ($value) { if (!$value && array_key_exists('_id', $this->attributes)) {
// Return _id as string $value = $this->attributes['_id'];
if ($value instanceof MongoId) {
return (string) $value;
}
return $value;
} }
if (array_key_exists('_id', $this->attributes)) // Return _id as string
{ if ($value instanceof MongoId) {
// Return _id as string return (string) $value;
if ($this->attributes['_id'] instanceof MongoId) {
return (string) $this->attributes['_id'];
}
return $this->attributes['_id'];
} }
return $value;
} }
/** /**
......
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