|
@@ 149-156 (lines=8) @@
|
| 146 |
|
$method = $config['method']; |
| 147 |
|
$maxLength = $config['maxLength']; |
| 148 |
|
|
| 149 |
|
if ($method === null) { |
| 150 |
|
$slugEngine = $this->getSlugEngine($attribute); |
| 151 |
|
$slug = $slugEngine->slugify($source, $separator); |
| 152 |
|
} elseif (is_callable($method)) { |
| 153 |
|
$slug = call_user_func($method, $source, $separator); |
| 154 |
|
} else { |
| 155 |
|
throw new \UnexpectedValueException('Sluggable "method" for ' . get_class($this->model) . ':' . $attribute . ' is not callable nor null.'); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
if (is_string($slug) && $maxLength) { |
| 159 |
|
$slug = mb_substr($slug, 0, $maxLength); |
|
@@ 259-265 (lines=7) @@
|
| 256 |
|
} |
| 257 |
|
|
| 258 |
|
$method = $config['uniqueSuffix']; |
| 259 |
|
if ($method === null) { |
| 260 |
|
$suffix = $this->generateSuffix($slug, $separator, $list); |
| 261 |
|
} elseif (is_callable($method)) { |
| 262 |
|
$suffix = call_user_func($method, $slug, $separator, $list); |
| 263 |
|
} else { |
| 264 |
|
throw new \UnexpectedValueException('Sluggable "reserved" for ' . get_class($this->model) . ':' . $attribute . ' is not null, an array, or a closure that returns null/array.'); |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
return $slug . $separator . $suffix; |
| 268 |
|
} |