Пример #1
0
 /**
  * Save a new model and attach it to the parent model.
  *
  * @param  \Nova\Database\ORM\Model  $model
  * @param  array  $joining
  * @param  bool   $touch
  * @return \Nova\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;
 }
Пример #2
0
 /**
  * Attach a model instance to the parent model.
  *
  * @param  \Nova\Database\ORM\Model  $model
  * @return \Nova\Database\ORM\Model
  */
 public function save(Model $model)
 {
     $model->setAttribute($this->getPlainForeignKey(), $this->getParentKey());
     return $model->save() ? $model : false;
 }