protected function generateSlug($source, array $config, $attribute)
{
$separator = $config['separator'];
$method = $config['method'];
$maxLength = $config['maxLength'];
if ($method === null) {
$slugEngine = $this->getSlugEngine($attribute);
$slug = $slugEngine->slugify($source, $separator);
} elseif (is_callable($method)) {
$slug = call_user_func($method, $source, $separator);
} else {
throw new \UnexpectedValueException('Sluggable "method" for ' . get_class($this->model) . ':' . $attribute . ' is not callable nor null.');
}
if (is_string($slug) && $maxLength) {
$slug = mb_substr($slug, 0, $maxLength);
}
return $slug;
}