email !== $user->email) { return Result::WrongEmail; } $workspacesGone = DB::transaction(function () use ($invite): bool { $lockedInvite = Invite::query() ->whereKey($invite->id) ->lockForUpdate() ->first(); if (! $lockedInvite) { return true; } $workspaces = ResolveInviteWorkspaces::execute($lockedInvite); $lockedInvite->delete(); return $workspaces->isEmpty(); }); return $workspacesGone ? Result::Gone : Result::Declined; } }