|
@@ 159-166 (lines=8) @@
|
| 156 |
|
$maxLength = $config['maxLength']; |
| 157 |
|
$maxLengthKeepWords = $config['maxLengthKeepWords']; |
| 158 |
|
|
| 159 |
|
if ($method === null) { |
| 160 |
|
$slugEngine = $this->getSlugEngine($attribute); |
| 161 |
|
$slug = $slugEngine->slugify($source, $separator); |
| 162 |
|
} elseif (is_callable($method)) { |
| 163 |
|
$slug = call_user_func($method, $source, $separator); |
| 164 |
|
} else { |
| 165 |
|
throw new \UnexpectedValueException('Sluggable "method" for '.get_class($this->model).':'.$attribute.' is not callable nor null.'); |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
$len = mb_strlen($slug); |
| 169 |
|
if (is_string($slug) && $maxLength && $len > $maxLength) { |
|
@@ 235-241 (lines=7) @@
|
| 232 |
|
if (is_array($reserved)) { |
| 233 |
|
if (in_array($slug, $reserved)) { |
| 234 |
|
$method = $config['uniqueSuffix']; |
| 235 |
|
if ($method === null) { |
| 236 |
|
$suffix = $this->generateSuffix($slug, $separator, collect($reserved)); |
| 237 |
|
} elseif (is_callable($method)) { |
| 238 |
|
$suffix = $method($slug, $separator, collect($reserved)); |
| 239 |
|
} else { |
| 240 |
|
throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for '.get_class($this->model).':'.$attribute.' is not null, or a closure.'); |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
return $slug.$separator.$suffix; |
| 244 |
|
} |
|
@@ 300-306 (lines=7) @@
|
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
$method = $config['uniqueSuffix']; |
| 300 |
|
if ($method === null) { |
| 301 |
|
$suffix = $this->generateSuffix($slug, $separator, $list); |
| 302 |
|
} elseif (is_callable($method)) { |
| 303 |
|
$suffix = $method($slug, $separator, $list); |
| 304 |
|
} else { |
| 305 |
|
throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for '.get_class($this->model).':'.$attribute.' is not null, or a closure.'); |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
return $slug.$separator.$suffix; |
| 309 |
|
} |