FEATURE: move user roles into separate enumeration.
This commit moves list of user roles into separate class (with own namespace), so we can access this data anywhere from application.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?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
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user