adding transaction

This commit is contained in:
Amine Ben hammou
2018-10-04 11:56:54 +02:00
parent c51a3f208c
commit 8c44ef561c

View File

@ -77,8 +77,15 @@ class ScheduledTask extends Model {
} }
function delete() { function delete() {
ScheduledTaskSubscriber::where('task_id', $this->id)->deleteMany(); try {
return parent::delete(); \ORM::get_db()->beginTransaction();
ScheduledTaskSubscriber::where('task_id', $this->id)->deleteMany();
parent::delete();
\ORM::get_db()->commit();
} catch(\Exception $error) {
\ORM::get_db()->rollBack();
throw $error;
}
} }
static function touchAllByIds(array $ids) { static function touchAllByIds(array $ids) {