Cviebrock\EloquentSluggable\Services\SlugService::generateSuffix PHP 메소드

generateSuffix() 보호된 메소드

Generate a unique suffix for the given slug (and list of existing, "similar" slugs.
protected generateSuffix ( string $slug, string $separator, Collection $list ) : string
$slug string
$separator string
$list Illuminate\Support\Collection
리턴 string
    protected function generateSuffix($slug, $separator, Collection $list)
    {
        $len = strlen($slug . $separator);
        // If the slug already exists, but belongs to
        // our model, return the current suffix.
        if ($list->search($slug) === $this->model->getKey()) {
            $suffix = explode($separator, $slug);
            return end($suffix);
        }
        $list->transform(function ($value, $key) use($len) {
            return intval(substr($value, $len));
        });
        // find the highest value and return one greater.
        return $list->max() + 1;
    }