kakallatt
10 months ago

Laravel Trigger Model Event on Relation Deleting

Posted 10 months ago by kakallatt

I have 2 events on 2 models.

User model:

static::deleting(function ($user) {
       
        $user->team()->deletel();
});

Team model:

static::deleting(function ($team) {
        self::transferMembers($team);
});

Expectation: When admin delete a user, the team belongs to that user will be deleted and other users in that team should be transferred to the default team.

Reality: The team was deleted but it didn't trigger the deleting event to transfer members to default team.

Thank you for your helping!

Please sign in or create an account to participate in this conversation.