/** * @param \Notadd\Foundation\Database\Eloquent\Model $model * @param array $joining * @param bool $touch * @return \Notadd\Foundation\Database\Eloquent\Model */ public function save(Model $model, array $joining = [], $touch = true) { $model->save(['touch' => false]); $this->attach($model->getKey(), $joining, $touch); return $model; }
/** * @param \Notadd\Foundation\Database\Eloquent\Model $model * @return \Notadd\Foundation\Database\Eloquent\Model */ public function associate($model) { $this->parent->setAttribute($this->foreignKey, $model->getKey()); $this->parent->setAttribute($this->morphType, $model->getMorphClass()); return $this->parent->setRelation($this->relation, $model); }