mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-07 19:49:59 -05:00
remove: slugs
This commit is contained in:
@@ -30,7 +30,6 @@ class Poll extends Model
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'slug',
|
||||
'multiple_choice',
|
||||
];
|
||||
|
||||
@@ -69,17 +68,6 @@ class Poll extends Model
|
||||
$this->attributes['title'] = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create A Poll Title Slug.
|
||||
*/
|
||||
public function makeSlugFromTitle($title): string
|
||||
{
|
||||
$slug = \strlen((string) $title) > 20 ? \substr(Str::slug($title), 0, 20) : Str::slug($title);
|
||||
$count = $this->where('slug', 'LIKE', '%'.$slug.'%')->count();
|
||||
|
||||
return $count ? \sprintf('%s-%s', $slug, $count) : $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Total Votes On A Poll Option.
|
||||
*/
|
||||
@@ -92,16 +80,4 @@ class Poll extends Model
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected static function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
self::creating(function ($poll) {
|
||||
if (empty($poll->slug)) {
|
||||
$poll->slug = $poll->makeSlugFromTitle($poll->title);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user