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

Refactor _id attribute getter

parent 1722daf4
......@@ -49,7 +49,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
*/
public function getIdAttribute($value)
{
if ($value) {
if (!$value && array_key_exists('_id', $this->attributes)) {
$value = $this->attributes['_id'];
}
// Return _id as string
if ($value instanceof MongoId) {
return (string) $value;
......@@ -58,17 +61,6 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
return $value;
}
if (array_key_exists('_id', $this->attributes))
{
// Return _id as string
if ($this->attributes['_id'] instanceof MongoId) {
return (string) $this->attributes['_id'];
}
return $this->attributes['_id'];
}
}
/**
* Define an embedded one-to-many relationship.
*
......
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