Fix MySQL foreign key constraint error on Group delete

This commit is contained in:
Bubka 2021-10-03 21:49:48 +02:00
parent b79570bcd9
commit 69c3f08f7b

View File

@ -41,6 +41,24 @@ class Group extends Model
];
/**
* Override The "booting" method of the model
*
* @return void
*/
protected static function boot()
{
parent::boot();
static::deleting(function ($model) {
TwoFAccount::where('group_id', $model->id)
->update(
['group_id' => NULL]
);
});
}
/**
* Get the TwoFAccounts of the group.
*/