I'm trying to implement soft deleting in Laravel.
Here are my relationships
Tournament ( hasMany ) CategoryTournament (hasOne) CategorySettings
Tournament ( hasMany ) CategoryTournament (belongsToMany) CategoryTournamentUser
So, I used this answer that help me a lot
Now, when I SoftDelete a Tournament, all CategoryTournaments related are also deleted.
But then, I tried to apply it recursively, so I wrote the same code in CategoryTournament Model:
static::deleting(function($categoryTournament) {
$categoryTournament->settings()->delete();
$categoryTournament->users()->delete();
});
But this code is never ran. I checked that I have settings and user to delete, but none of them are soft deleted...
Did I miss something??? It should work!
EDIT:
Now, I am trying to Soft Delete a User, it is just one more level:
User (HasMany) Tournament ( hasMany ) CategoryTournament (hasOne) CategorySettings
So now, when I soft Delete user, it delete his tournaments, but it doesn't delete anymore his CategoryTournaments, so this is not a config error.