-
Notifications
You must be signed in to change notification settings - Fork 3
Roles & Permissions
Creating a Role - Get Roles - Deleting a Role - Setting a User Role - Get User Roles - Delete User Role - Get Role Permissions - Add Role Permissions - Remove Role Permissions
Access to the Roles and Permissions API requires a sudo token.
@param array $role
@return bool
Chatkit::roles()->store($role);
scope
(string|required): Scope of the new role; one of global
or room
.
name
(string|required): Name of the new role.
permissions
(array|required): Permissions assigned to the role.
Example
$created = Chatkit::roles()->store([
'name' => 'Test role',
'scope' => 'global',
'permissions' => ['room:join', 'room:leave']
]);
@return \Illuminate\Support\Collection
Example
$roles = Chatkit::roles()->index();
@param string $roleName
@param string $scopeName
@return \Illuminate\Support\Collection
scopeName
(string|required): Scope of the role; one of global
or room
.
Example
$role = new \Chess\Chatkit\Models\Role($roleName);
$deleted = $role->scope($scopeName)->delete();
@param string $userId
@param array $role
@param int|optional $roomId
@return bool
$user->roles()->assign($role);
name
(string|required): Name of the role.
room_id
(integer|optional): The ID of the room you want to set the user role for. If no room_id value is provided then the scope will be global.
Example
$user = new \Chess\Chatkit\Models\User($userId);
$assigned = $user->roles()->assign([
'name' => 'Super Test',
'room_id' => $roomId
]);
@param string $userId
@return \Illuminate\Support\Collection
Example
$user = new \Chess\Chatkit\Models\User($userId);
$roles = $user->roles()->get();
@param string $userId
@param int|optional $roomId
@return bool
roomId
(integer|optional): The ID of the room you want to delete the user role for. If not provided then if the userId
has an associated (non-default) user role at the global scope, that will be deleted.
Example
$user = new \Chess\Chatkit\Models\User($userId);
$deleted = $user->roles()->delete(); // global scope
OR with room scope
$user = new \Chess\Chatkit\Models\User($userId);
$deleted = $user->roles()->delete($roomId); // room scope
@param string $roleName
@param string $scopeName
@return array
scopeName
(string|required): Scope of the role; one of global
or room
.
Example
$role = new \Chess\Chatkit\Models\Role($roleName);
$permissions = $role->scope($scopeName)->permissions()->get();
@param string $roleName
@param string $scopeName
@param array $permissions
@return bool
$role->scope($scopeName)->permissions()->add($permissions);
scopeName
(string|required): Scope of the role; one of global
or room
.
Example
$role = new \Chess\Chatkit\Models\Role($roleName);
$added = $role->scope($scopeName)->permissions()->add([
'room:typing_indicator:create',
'room:update'
]);
@param string $roleName
@param string $scopeName
@param array $permissions
@return bool
$role->scope($scopeName)->permissions()->remove($permissions);
scopeName
(string|required): Scope of the role; one of global
or room
.
Example
$role = new \Chess\Chatkit\Models\Role($roleName);
$removed = $role->scope($scopeName)->permissions()->remove([
'room:typing_indicator:create',
'room:update'
]);