|
@@ 183-190 (lines=8) @@
|
| 180 |
|
$maxLength = $config['maxLength']; |
| 181 |
|
$maxLengthKeepWords = $config['maxLengthKeepWords']; |
| 182 |
|
|
| 183 |
|
if ($method === null) { |
| 184 |
|
$slugEngine = $this->getSlugEngine($attribute); |
| 185 |
|
$slug = $slugEngine->slugify($source, $separator); |
| 186 |
|
} elseif (is_callable($method)) { |
| 187 |
|
$slug = call_user_func($method, $source, $separator); |
| 188 |
|
} else { |
| 189 |
|
throw new \UnexpectedValueException('Sluggable "method" for ' . get_class($this->model) . ':' . $attribute . ' is not callable nor null.'); |
| 190 |
|
} |
| 191 |
|
|
| 192 |
|
$len = mb_strlen($slug); |
| 193 |
|
if (is_string($slug) && $maxLength && $len > $maxLength) { |
|
@@ 259-265 (lines=7) @@
|
| 256 |
|
if (is_array($reserved)) { |
| 257 |
|
if (in_array($slug, $reserved)) { |
| 258 |
|
$method = $config['uniqueSuffix']; |
| 259 |
|
if ($method === null) { |
| 260 |
|
$suffix = $this->generateSuffix($slug, $separator, collect($reserved)); |
| 261 |
|
} elseif (is_callable($method)) { |
| 262 |
|
$suffix = $method($slug, $separator, collect($reserved)); |
| 263 |
|
} else { |
| 264 |
|
throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.'); |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
return $slug . $separator . $suffix; |
| 268 |
|
} |
|
@@ 324-330 (lines=7) @@
|
| 321 |
|
} |
| 322 |
|
|
| 323 |
|
$method = $config['uniqueSuffix']; |
| 324 |
|
if ($method === null) { |
| 325 |
|
$suffix = $this->generateSuffix($slug, $separator, $list); |
| 326 |
|
} elseif (is_callable($method)) { |
| 327 |
|
$suffix = $method($slug, $separator, $list); |
| 328 |
|
} else { |
| 329 |
|
throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.'); |
| 330 |
|
} |
| 331 |
|
|
| 332 |
|
return $slug . $separator . $suffix; |
| 333 |
|
} |