mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Merge pull request #121 from jack126guy/easy-slug-fix
Ensure that slug is always nonempty
This commit is contained in:
commit
6cc959069f
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