If the pivot model fails for some reason, abort the sync

Refs #1408
This commit is contained in:
Samuel Georges 2015-09-12 07:53:33 +10:00
parent 1d5caee2d9
commit e8b4bf9d72

View File

@ -1111,6 +1111,10 @@ class RelationController extends ControllerBehavior
{
$this->beforeAjax();
/*
* If the pivot model fails for some reason, abort the sync
*/
Db::transaction(function () {
/*
* Add the checked IDs to the pivot table
*/
@ -1130,6 +1134,7 @@ class RelationController extends ControllerBehavior
$modelToSave->save();
}
}
});
return ['#'.$this->relationGetId('view') => $this->relationRenderView()];
}