/** * Set a given attribute on the model. * * @param string $key * @param mixed $value * @return void */ public function setAttribute($key, $value) { // Convert _id to MongoId. if ($key == '_id' and is_string($value)) { $builder = $this->newBaseQueryBuilder(); $value = $builder->convertKey($value); } elseif (str_contains($key, '.')) { if (in_array($key, $this->getDates()) && $value) { $value = $this->fromDateTime($value); } array_set($this->attributes, $key, $value); return; } parent::setAttribute($key, $value); }
/** * Set a given attribute on the model. * * @param string $key * @param mixed $value * @return void */ public function setAttribute($key, $value) { // Convert _id to MongoId. if ($key == '_id' and is_string($value)) { $this->attributes[$key] = new MongoId($value); } else { parent::setAttribute($key, $value); } }