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