/** * Saves the model instance to database. If necessary, it will purge the model attributes * of unnecessary fields. It will also replace plain-text password fields with their hashes. * * @param array $options * @return bool */ protected function performSave(array $options) { if ($this->autoPurgeRedundantAttributes) { $this->attributes = $this->purgeArray($this->attributes); } if ($this->autoHashPasswordAttributes) { $this->attributes = $this->hashPasswordAttributes($this->attributes, static::$passwordAttributes); } return parent::save($options); }
/** * Save a new model and attach it to the parent model. * * @param \LMongo\Eloquent\Model $model * @return \LMongo\Eloquent\Model */ public function save(Model $model) { $model->save(); $this->attach($model); return $model; }
/** * Attach a model instance to the parent model. * * @param \LMongo\Eloquent\Model $model * @return \LMongo\Eloquent\Model */ public function save(Model $model) { $model->setAttribute($this->foreignKey, new MongoID($this->parent->getKey())); return $model->save() ? $model : false; }