mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 13:07:59 +01:00
Ensure that slug is always nonempty
Fixes #119 <https://github.com/Poniverse/Pony.fm/issues/119>
This commit is contained in:
parent
2de284963e
commit
4108b8f90b
1 changed files with 9 additions and 1 deletions
|
@ -26,7 +26,15 @@ trait SlugTrait
|
||||||
{
|
{
|
||||||
public function setTitleAttribute($value)
|
public function setTitleAttribute($value)
|
||||||
{
|
{
|
||||||
$this->slug = Str::slug($value);
|
$this->slug = self::makeNonemptySlug($value);
|
||||||
$this->attributes['title'] = $value;
|
$this->attributes['title'] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function makeNonemptySlug($title) {
|
||||||
|
$slug = Str::slug($title);
|
||||||
|
if ($slug === '') {
|
||||||
|
$slug = '-';
|
||||||
|
}
|
||||||
|
return $slug;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue