Archived
1
0
Fork 0

app/Models/User.php: Also delete characters when deleting the user.

This commit is contained in:
Henrik Hautakoski 2021-07-13 18:33:19 +02:00
parent 866b374070
commit f09fea4f08

View file

@ -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);