-
Notifications
You must be signed in to change notification settings - Fork 3
Rooms
Create a Room - Fetch a Room - Fetch Rooms - Delete a Room - Update a Room - Add Users - Remove Users
@param array $room
@return \Chess\Chatkit\Models\Room
Chatkit::rooms()->store($room);
Note that leaving the request body empty means that a room will be created with an automatically assigned name and no users.
name
(string|optional): Represents the name with which the room is identified. A room name must not be longer than 40 characters and can only contain lowercase letters, numbers, underscores and hyphens.
private
(boolean|optional): Indicates if a room should be private or public. By default, it is private.
user_ids
(array|optional): If you wish to add users to the room at the point of creation, you may provide their user IDs.
Example
$room = Chatkit::rooms()->store([
'name' => 'my-cool-room',
'private' => false, // default true
'user_ids' => [],
]);
@param int $roomId
@return \Chess\Chatkit\Models\Room
Example
$room = Chatkit::rooms()->show($roomId);
@param int $fromId
@return \Illuminate\Support\Collection
The number of room returned is at most 20 per request.
fromId
(int|optional): ID (exclusive) from which rooms with larger IDs should be returned.
Example
$rooms = Chatkit::rooms()->index();
OR with From Id
$rooms = Chatkit::rooms()->index($fromId);
@param int $roomId
@return bool
Example
$deleted = Chatkit::rooms()->destroy($roomId);
@param int $roomId
@param array $roomData
@return bool
Chatkit::rooms()->update($roomId, $roomData);
Note that updating a room will return no response body. Updated resources must be fetched using a subsequent request.
name
(string|optional): New name for the room.
private
(boolean|optional): Indicates if a room should be private or public.
Example
$updated = Chatkit::rooms()->update($roomId, [
'name' => 'Empire state of room',
'private' => false,
]);
@param int $roomId
@param array $userIds
@return bool
$room->users()->add($userIds);
userIds
(array|optional): List of user IDs to add to the room.
Example
$room = new \Chess\Chatkit\Models\Room($roomId);
$added = $room->users()->add([
$userIdOne, $userIdTwo
]);
@param int $roomId
@param array $userIds
@return bool
$room->users()->remove($userIds);
userIds
(array|optional): List of user id's to remove from the room.
Example
$room = new \Chess\Chatkit\Models\Room($roomId);
$removed = $room->users()->remove([
$userIdOne, $userIdTwo
]);