Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.
Pascal Boucher edited this page Jun 11, 2018 · 1 revision

Shortcuts

Create a Room - Fetch a Room - Fetch Rooms - Delete a Room - Update a Room - Add Users - Remove Users

Create a Room

@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' => [],
]);

Api reference

Fetch a Room

@param  int $roomId
@return \Chess\Chatkit\Models\Room

Example

$room = Chatkit::rooms()->show($roomId);

Api reference

Fetch Rooms

@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);

Api reference

Delete a Room

@param  int $roomId
@return bool

Example

$deleted = Chatkit::rooms()->destroy($roomId);

Api reference

Update a Room

@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,
]);

Api reference

Add Users

@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
]);

Api reference

Remove Users

@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
]);

Api reference

Clone this wiki locally