BookStack\Repos\ChapterRepo::findSuitableSlug PHP Method

findSuitableSlug() public method

Checks database to prevent duplicate slugs.
public findSuitableSlug ( $name, $bookId, boolean | false $currentId = false ) : string
$name
$bookId
$currentId boolean | false
return string
    public function findSuitableSlug($name, $bookId, $currentId = false)
    {
        $slug = $this->nameToSlug($name);
        while ($this->doesSlugExist($slug, $bookId, $currentId)) {
            $slug .= '-' . substr(md5(rand(1, 500)), 0, 3);
        }
        return $slug;
    }