Skip to content

Instantly share code, notes, and snippets.

@BrightnBubbly
Created April 28, 2020 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrightnBubbly/b57b28c05a725468ade3dd191e6bc21c to your computer and use it in GitHub Desktop.
Save BrightnBubbly/b57b28c05a725468ade3dd191e6bc21c to your computer and use it in GitHub Desktop.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use GetStream\StreamChat\Client as StreamClient;
use App\User;
use Illuminate\Support\Facades\Hash;
class InitializeChannel extends Command
{
protected $signature = 'channel:init';
protected $description = 'Initialize channel with admin user';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$user = new User;
$user->username = 'mezie';
$user->email = 'chimezie@adonismastery.com';
$user->is_admin = true;
$user->password = Hash::make('password');
$user->save();
$client = new StreamClient(
env('MIX_STREAM_API_KEY'),
env('MIX_STREAM_API_SECRET'),
null,
null,
9
);
$client->updateUser([
'id' => $user->username,
'name' => $user->username,
'role' => 'admin'
]);
$channel = $client->Channel('messaging', 'Chatroom', [
'created_by' => $user->username,
]);
$channel->addMembers([$user->username]);
return $this->info('Channel initialized');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment