예제 #1
0
 /**
  * Attach a model instance to the parent model.
  *
  * This adds the field_id value
  *
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function save(Model $model)
 {
     if ($this->fieldId) {
         $model->setAttribute($this->fieldKey, $this->fieldId);
     }
     return parent::save($model);
 }
예제 #2
0
 /**
  * Attach a model instance to the parent model and trigger revisions.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $model
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function save(Model $model)
 {
     $this->parent->preSaveChild($this->relation, $model);
     if ($model = parent::save($model)) {
         $this->parent->postSaveChild($this->relation, $model);
     }
     return $model;
 }