This commit moves list of user roles into separate class (with own namespace), so we can access this data anywhere from application.
35 lines
859 B
PHP
35 lines
859 B
PHP
<?php
|
|
namespace App\Enumerations;
|
|
|
|
use App\Models\User;
|
|
|
|
class UserRoles
|
|
{
|
|
/**
|
|
* Getter for roles
|
|
*
|
|
* This method returns only list of roles as inserted into database
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getSimple()
|
|
{
|
|
return array_values(self::getWithTranslations());
|
|
}
|
|
|
|
/**
|
|
* Getter for roles with translations
|
|
*
|
|
* This method returns all user roles as keys. Values are strings used for translations.
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getWithTranslations()
|
|
{
|
|
return [
|
|
User::ROLE_ADMIN => 'admin/userManagement.role_' . User::ROLE_ADMIN,
|
|
User::ROLE_EDITOR => 'admin/userManagement.role_' . User::ROLE_EDITOR,
|
|
User::ROLE_VISITOR => 'admin/userManagement.role_' . User::ROLE_VISITOR
|
|
];
|
|
}
|
|
} |