X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/4b36df08a80f467c037de3bbdf85e13cd4cef9bc..refs/pull/3113/head:/app/Auth/Role.php diff --git a/app/Auth/Role.php b/app/Auth/Role.php index 255158afb..71da88e19 100644 --- a/app/Auth/Role.php +++ b/app/Auth/Role.php @@ -1,29 +1,37 @@ -belongsToMany(User::class)->orderBy('name', 'asc'); } @@ -39,7 +47,7 @@ class Role extends Model implements Loggable /** * The RolePermissions that belong to the role. */ - public function permissions() + public function permissions(): BelongsToMany { return $this->belongsToMany(RolePermission::class, 'permission_role', 'role_id', 'permission_id'); } @@ -55,6 +63,7 @@ class Role extends Model implements Loggable return true; } } + return false; } @@ -77,7 +86,7 @@ class Role extends Model implements Loggable /** * Get the role of the specified display name. */ - public static function getRole(string $displayName): ?Role + public static function getRole(string $displayName): ?self { return static::query()->where('display_name', '=', $displayName)->first(); } @@ -85,13 +94,13 @@ class Role extends Model implements Loggable /** * Get the role object for the specified system role. */ - public static function getSystemRole(string $systemName): ?Role + public static function getSystemRole(string $systemName): ?self { return static::query()->where('system_name', '=', $systemName)->first(); } /** - * Get all visible roles + * Get all visible roles. */ public static function visible(): Collection { @@ -103,11 +112,14 @@ class Role extends Model implements Loggable */ public static function restrictable(): Collection { - return static::query()->where('system_name', '!=', 'admin')->get(); + return static::query() + ->where('system_name', '!=', 'admin') + ->orderBy('display_name', 'asc') + ->get(); } /** - * @inheritdoc + * {@inheritdoc} */ public function logDescriptor(): string {