app/Models/User.php: Also delete characters when deleting the user.
This commit is contained in:
parent
866b374070
commit
f09fea4f08
1 changed files with 9 additions and 0 deletions
|
|
@ -43,6 +43,15 @@ class User extends Authenticatable
|
|||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleted(function ($user) {
|
||||
$user->characters()->delete();
|
||||
});
|
||||
}
|
||||
|
||||
public function characters()
|
||||
{
|
||||
return $this->hasMany(Character::class);
|
||||
|
|
|
|||
Reference in a new issue