Skip to content

Instantly share code, notes, and snippets.

@ammezie ammezie/RegisterController.php Secret
Created Sep 30, 2019

Embed
What would you like to do?
// app/Http/Controllers/Auth/RegisterController.php
// first import StreamChat PHP client
use GetStream\StreamChat\Client as StreamClient;
protected function registered($user){
$client = new StreamClient(env("MIX_STREAM_API_KEY"), env("MIX_STREAM_API_SECRET"), null, null, 9);
$username = explode('@', $user->email)[0];
// create the user on Stream Chat
$client->updateUser([
'id' => $username,
'name' => $user->name,
]);
// create channel
$channel = $client->Channel("messaging", "chatroom");
// channel is created by `admin` user
$channel->create('admin');
// then add the newly registered user as a member
$channel->addMembers([$username]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.