diff --git a/app/Models/User.php b/app/Models/User.php index b0418cb..0688289 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -165,6 +165,17 @@ class User extends Authenticatable return $slug; } + protected static function boot() + { + parent::boot(); + + static::creating(function ($user) { + if (empty($user->slug)) { + $user->slug = static::generateUniqueSlug($user->name); + } + }); + } + /** * Get the route key for the model. */