src/Database/Models/Traits/Sluggable.php
/**
     * Increments the number appended to the slug, to prevent duplicates.
     *
     * @param string $slug
     *
     * @return string
     */
Increments the number appended to the slug, to prevent duplicates.
@param string $slug

@return string
Increments the number appended to the slug to prevent duplicates . @param string $slug @return string
protected function incrementLatestSlug($slug)
    {
        $highest = static::where('slug', 'like', "$slug-%")->orderBy('slug', 'desc')->first();
        $num = 1;
        if ($highest) {
            $num = str_replace("$slug-", '', $highest->getAttribute('slug'));
            $num++;
        }
        return $slug.'-'.$num;
    }
protected function incrementLatestSlug ( $ slug ) { $ highest = static :: where ( 'slug' , 'like' , " $ slug -% " ) -> orderBy ( 'slug' , 'desc' ) -> first ( ) ; $ num = 1 ; if ( $ highest ) { $ num = str_replace ( " $ slug - " , '' , $ highest -> getAttribute ( 'slug' ) ) ; $ num ++ ; } return $ slug . '-' . $ num ; }
Increments the number appended to the slug, to prevent duplicates.
Increments the number appended to the slug to prevent duplicates .