LMongo\Eloquent\Relations\HasOneOrMany::save PHP Method

save() public method

Attach a model instance to the parent model.
public save ( Model $model ) : Model
$model LMongo\Eloquent\Model
return LMongo\Eloquent\Model
    public function save(Model $model)
    {
        $model->setAttribute($this->foreignKey, new MongoID($this->parent->getKey()));
        return $model->save() ? $model : false;
    }

Usage Example

Beispiel #1
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->morphType, $this->morphClass);
     return parent::save($model);
 }