-
-
Save ammezie/530169be0b2d64b4f4acbfb9388f2e3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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