public function generateIdSlug()
    {
        $slug = Slug::fromId($this->getKey());

        // Ensure slug is unique (since the fromId() algorithm doesn't produce unique slugs)
        $attempts = 10;
        while ($this->isExistingSlug($slug)) {
            if ($attempts <= 0) {
                throw new UnableToCreateSlugException(
                    "Unable to find unique slug for record '{$this->getKey()}', tried 10 times..."
                );
            }

            $slug = Slug::random();
            $attempts--;
        }

        $this->setSlugValue($slug);
    }
public function generateIdSlug()
    {
        $slug = Slug::fromId($this->getKey());

        // Ensure slug is unique (since the fromId() algorithm doesn't produce unique slugs)
        $attempts = 10;
        while ($this->isExistingSlug($slug)) {
            if ($attempts <= 0) {
                throw new UnableToCreateSlugException(
                    "Unable to find unique slug for record '{$this->getKey()}', tried 10 times..."
                );
            }

            $slug = Slug::random();
            $attempts--;
        }

        $this->setSlugValue($slug);
    }
public function generateIdSlug ( ) { $ slug = Slug :: fromId ( $ this -> getKey ( ) ) ; // Ensure slug is unique (since the fromId() algorithm doesn't produce unique slugs) $ attempts = 10 ; while ( $ this -> isExistingSlug ( $ slug ) ) { if ( $ attempts <= 0 ) { throw new UnableToCreateSlugException ( "Unable to find unique slug for record '{$this->getKey()}', tried 10 times..." ) ; } $ slug = Slug :: random ( ) ; $ attempts -- ; } $ this -> setSlugValue ( $ slug ) ; }
Generate a slug based on the main model key.
Generate a slug based on the main model key .