Exemplo n.º 1
0
 public function save(Model $model)
 {
     $model->save();
     $this->attach($model);
     return $model;
 }
Exemplo n.º 2
0
 /**
  * Detaches a child model from this model.
  *
  * @param Model $model child model
  *
  * @return self
  */
 public function detach(Model $model)
 {
     $model->{$this->foreignKey} = null;
     $model->save();
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Attaches a child model to this model.
  *
  * @param Model $model child model
  *
  * @return self
  */
 public function attach(Model $model)
 {
     $model->{$this->foreignKey} = $this->localModel->{$this->localKey};
     $model->save();
     return $this;
 }