protected function finalizeSlug($slug)
    {
        $prefix = $this->slugPrefix();
        if ($prefix) {
            $prefix = $this->generateRoutePattern((string)$prefix);
            if ($slug === $prefix) {
                throw new UnexpectedValueException('The slug is the same as the prefix.');
            }
            $slug = $prefix.preg_replace('!^'.preg_quote($prefix).'\b!', '', $slug);
        }

        $suffix = $this->slugSuffix();
        if ($suffix) {
            $suffix = $this->generateRoutePattern((string)$suffix);
            if ($slug === $suffix) {
                throw new UnexpectedValueException('The slug is the same as the suffix.');
            }
            $slug = preg_replace('!\b'.preg_quote($suffix).'$!', '', $slug).$suffix;
        }

        $slug = rtrim($slug, '/');

        return $slug;
    }
protected function finalizeSlug($slug)
    {
        $prefix = $this->slugPrefix();
        if ($prefix) {
            $prefix = $this->generateRoutePattern((string)$prefix);
            if ($slug === $prefix) {
                throw new UnexpectedValueException('The slug is the same as the prefix.');
            }
            $slug = $prefix.preg_replace('!^'.preg_quote($prefix).'\b!', '', $slug);
        }

        $suffix = $this->slugSuffix();
        if ($suffix) {
            $suffix = $this->generateRoutePattern((string)$suffix);
            if ($slug === $suffix) {
                throw new UnexpectedValueException('The slug is the same as the suffix.');
            }
            $slug = preg_replace('!\b'.preg_quote($suffix).'$!', '', $slug).$suffix;
        }

        $slug = rtrim($slug, '/');

        return $slug;
    }
protected function finalizeSlug ( $ slug ) { $ prefix = $ this -> slugPrefix ( ) ; if ( $ prefix ) { $ prefix = $ this -> generateRoutePattern ( ( string ) $ prefix ) ; if ( $ slug === $ prefix ) { throw new UnexpectedValueException ( 'The slug is the same as the prefix.' ) ; } $ slug = $ prefix . preg_replace ( '!^' . preg_quote ( $ prefix ) . '\b!' , '' , $ slug ) ; } $ suffix = $ this -> slugSuffix ( ) ; if ( $ suffix ) { $ suffix = $ this -> generateRoutePattern ( ( string ) $ suffix ) ; if ( $ slug === $ suffix ) { throw new UnexpectedValueException ( 'The slug is the same as the suffix.' ) ; } $ slug = preg_replace ( '!\b' . preg_quote ( $ suffix ) . '$!' , '' , $ slug ) . $ suffix ; } $ slug = rtrim ( $ slug , '/' ) ; return $ slug ; }
Finalize slug.

Adds any prefix and suffix defined in the routable configuration set.

@param  string $slug A slug.
@throws UnexpectedValueException If the slug affixes are invalid.
@return string
Finalize slug .