mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-26 18:25:09 +01:00
Fix MySQL foreign key constraint error on Group delete
This commit is contained in:
parent
b79570bcd9
commit
69c3f08f7b
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user