/** * Save a new model and attach it to the parent model. * * @param \Database\ORM\Model $model * @param array $joining * @param bool $touch * @return \Database\ORM\Model */ public function save(Model $model, array $joining = array(), $touch = true) { $model->save(array('touch' => false)); $this->attach($model->getKey(), $joining, $touch); return $model; }
/** * Attach a model instance to the parent model. * * @param \Database\ORM\Model $model * @return \Database\ORM\Model */ public function save(Model $model) { $model->setAttribute($this->getPlainForeignKey(), $this->getParentKey()); return $model->save() ? $model : false; }