Slug with random values

Hi there,

I want to have that the slugs for a specific page have random values. I have found this Thread but I am not able to build this in my instance. Maybe anyone can help me out a bit how to works this?

'hooks' => [
      'page.create:after' => function($page) {
        if ( str::startsWith($page->intendedTemplate(), 'block-' ) ) {
          $page->changeSlug('xxxxx');
        }
      }
    ]
         $newPage= page()->createChild([
            'slug' => Str::random(10,'alpha'),
            'template' => 'sometemplate',
            'content' => array(
              // data
                ),
            ]);

// Make sure you have enough permissions to do the job...
$newPage->changeSlug(Str::random(10,'alpha'));