I have not tested it but I think this should work. I also added the changeTitle method as this might be useful too here.
<?php
class CustomPage extends Page
{
/**
* Change the page title
*
* @param string $title
* @param string|null $languageCode
* @return static
*/
public function changeTitle(string $title, string $languageCode = null)
{
$page = parent::changeTitle($title, $languageCode);
return $page->changeSlug('my-new-slug', $languageCode);
}
/**
* Creates and stores a new page
*
* @param array $props
* @return static
*/
public static function create(array $props)
{
$props['slug'] = 'my-new-slug';
return parent::create($props);
}
/**
* Updates the page data
*
* @param array|null $input
* @param string|null $languageCode
* @param bool $validate
* @return static
*/
public function update(array $input = null, string $languageCode = null, bool $validate = false)
{
$page = parent::update($input, $languageCode, $validate);
return $page->changeSlug('my-new-slug', $languageCode);
}
}