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;
}