Found a nice and easy answer. For laravel 11.x you can just add to the User model and will do the trick
protected static function boot() {
parent::boot();
static::deleting(function($user) {
$user->projects()->update(['user_id' => null]);
});
}