ChannelRolePermission
Class · Sharkord\Models\ChannelRolePermission
Class ChannelRolePermission
Represents a single role-level permission entry for a channel, as returned by the channels.getPermissions RPC. Each entry corresponds to one ChannelPermissionFlag for one role, and carries an explicit allow/deny flag.
Examples
Section titled “Examples”$channel->getPermissions()->then(function(array $permissions) { foreach ($permissions['rolePermissions'] as $entry) { $state = $entry->allow ? 'allowed' : 'denied'; echo "Role {$entry->roleId} — {$entry->permission->value}: {$state}\n"; }});Methods
Section titled “Methods”__construct()
Section titled “__construct()”ChannelRolePermission constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$channelId | int | The ID of the channel this entry belongs to. |
$roleId | int | The ID of the role this entry belongs to. |
$permission | ChannelPermissionFlag | The permission flag this entry covers. |
$allow | bool | Whether the permission is granted (true) or denied (false). |
$createdAt | int | Unix timestamp (ms) when this entry was created. |
$updatedAt | ?int | Unix timestamp (ms) when this entry was last updated, or null. |
static fromArray()
Section titled “static fromArray()”Factory method to create a ChannelRolePermission from a raw API data array.
Parameters
| Parameter | Type | Description |
|---|---|---|
$raw | array | The raw permission entry from the server. |
Returns self
toArray()
Section titled “toArray()”Returns the permission entry as a plain array. Useful for debugging.
Returns array