Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,21 @@ public function save(Model $model, array $pivotAttributes = [], $touch = true)
return $model;
}

/**
* Save a new model without raising any events and attach it to the parent model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param array $pivotAttributes
* @param bool $touch
* @return \Illuminate\Database\Eloquent\Model
*/
public function saveQuietly(Model $model, array $pivotAttributes = [], $touch = true)
{
return Model::withoutEvents(function () use ($model, $pivotAttributes, $touch) {
return $this->save($model, $pivotAttributes, $touch);
});
}

/**
* Save an array of new models and attach them to the parent model.
*
Expand Down
13 changes: 13 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,19 @@ public function save(Model $model)
return $model->save() ? $model : false;
}

/**
* Attach a model instance without raising any events to the parent model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model|false
*/
public function saveQuietly(Model $model)
{
return Model::withoutEvents(function () use ($model) {
return $this->save($model);
});
}

/**
* Attach a collection of models to the parent instance.
*
Expand Down