mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Started rolling out user slugs to model and core controllers
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,14 @@ class UserRepo
|
||||
return User::query()->findOrFail($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user by their slug.
|
||||
*/
|
||||
public function getBySlug(string $slug): User
|
||||
{
|
||||
return User::query()->where('slug', '=', $slug)->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the users with their permissions.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user