-
-
Save BrightnBubbly/b57b28c05a725468ade3dd191e6bc21c 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
<?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