diff --git a/app/Traits/SlugTrait.php b/app/Traits/SlugTrait.php index c9c193dd..f290324e 100644 --- a/app/Traits/SlugTrait.php +++ b/app/Traits/SlugTrait.php @@ -26,7 +26,15 @@ trait SlugTrait { public function setTitleAttribute($value) { - $this->slug = Str::slug($value); + $this->slug = self::makeNonemptySlug($value); $this->attributes['title'] = $value; } + + private static function makeNonemptySlug($title) { + $slug = Str::slug($title); + if ($slug === '') { + $slug = '-'; + } + return $slug; + } }