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