Skip to content

Commit 4ebb1e5

Browse files
Updated automatic slug generation (does not override existing slug)
1 parent b8946d2 commit 4ebb1e5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/HasSlug.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ trait HasSlug
1515
public static function bootHasSlug()
1616
{
1717
static::saving(function($model) {
18-
$model->attributes[$model->getSlugStorageAttribute()] = $model->generateSlug();
18+
$attribute = $model->getSlugStorageAttribute();
19+
20+
if(!is_null($model->attributes[$attribute])) return;
21+
22+
$model->attributes[$attribute] = $model->generateSlug();
1923
});
2024
}
2125

0 commit comments

Comments
 (0)