public static function generateSlug(string $slug, array $usedSlugs)
    {
        $slug = camel_case($slug);
        $count = 1;

        // adds a number in the slug string if the specific slug allready exists
        if (in_array($slug, $usedSlugs)) {
            while(true){
                $slug = camel_case($slug."_".$count);
                if (!in_array($slug, $usedSlugs)) {
                    return $slug;
                }
                $count++;
            }
        }

        return $slug;
    }
public static function generateSlug(string $slug, array $usedSlugs)
    {
        $slug = camel_case($slug);
        $count = 1;

        // adds a number in the slug string if the specific slug allready exists
        if (in_array($slug, $usedSlugs)) {
            while(true){
                $slug = camel_case($slug."_".$count);
                if (!in_array($slug, $usedSlugs)) {
                    return $slug;
                }
                $count++;
            }
        }

        return $slug;
    }
public static function generateSlug ( string $ slug , array $ usedSlugs ) { $ slug = camel_case ( $ slug ) ; $ count = 1 ; // adds a number in the slug string if the specific slug allready exists if ( in_array ( $ slug , $ usedSlugs ) ) { while ( true ) { $ slug = camel_case ( $ slug . "_" . $ count ) ; if ( ! in_array ( $ slug , $ usedSlugs ) ) { return $ slug ; } $ count ++ ; } } return $ slug ; }
Generate slug of a field. Uses camel case to create the slug from a string.

@param  string $slug
@param  array  $usedSlugs
@return string
Generate slug of a field . Uses camel case to create the slug from a string .