]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/User.php
Extend /users API endpoint
[bookstack] / app / Auth / User.php
index 07232e1cc902f823427e7aec19db9e26fa37dab0..9855ab4e7408e86403f4e5c11757afc95af68241 100644 (file)
@@ -1,6 +1,7 @@
 <?php namespace BookStack\Auth;
 
 use BookStack\Api\ApiToken;
+use BookStack\Entities\Tools\SlugGenerator;
 use BookStack\Interfaces\Loggable;
 use BookStack\Interfaces\Sluggable;
 use BookStack\Model;
@@ -266,7 +267,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
      */
     public function getProfileUrl(): string
     {
-        return url('/user/' . $this->id);
+        return url('/user/' . $this->slug);
     }
 
     /**
@@ -303,4 +304,13 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
     {
         return "({$this->id}) {$this->name}";
     }
+
+    /**
+     * @inheritDoc
+     */
+    public function refreshSlug(): string
+    {
+        $this->slug = app(SlugGenerator::class)->generate($this);
+        return $this->slug;
+    }
 }