Repositories/Eloquent/EloquentSlugRepository.php
public function getSlugForTitle($title)
    {
        $slug = Str::slug($title);
        $latestSlug = $this->model->whereRaw("slug RLIKE '^{$slug}(-[0-9]*)?$'")->latest()->value('slug');

        if ($latestSlug) {
            $pieces = explode('-', $latestSlug);
            $number = end($pieces);

            return $slug.'-'.($number + 1);
        }

        return $slug;
    }
public function getSlugForTitle($title)
    {
        $slug = Str::slug($title);
        $latestSlug = $this->model->whereRaw("slug RLIKE '^{$slug}(-[0-9]*)?$'")->latest()->value('slug');

        if ($latestSlug) {
            $pieces = explode('-', $latestSlug);
            $number = end($pieces);

            return $slug.'-'.($number + 1);
        }

        return $slug;
    }
public function getSlugForTitle ( $ title ) { $ slug = Str :: slug ( $ title ) ; $ latestSlug = $ this -> model -> whereRaw ( "slug RLIKE '^{$slug}(-[0-9]*)?$'" ) -> latest ( ) -> value ( 'slug' ) ; if ( $ latestSlug ) { $ pieces = explode ( '-' , $ latestSlug ) ; $ number = end ( $ pieces ) ; return $ slug . '-' . ( $ number + 1 ) ; } return $ slug ; }
Generate a unique Slug for a given Title.

@param string $title

@return object
Generate a unique Slug for a given Title .