save() public method

Save the model to the database.
public save ( ) : boolean
return boolean
 /**
  * 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);
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * 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;
 }