app/Console/Commands/InitChannel.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
        $user = User::create([
            'username' => 'mezie',
            'email' => 'chimezie@adonismastery.com',
            'password' => bcrypt('password')
        ]);
        $twilio = new Client(env('TWILIO_AUTH_SID'), env('TWILIO_AUTH_TOKEN'));
        $channel = $twilio->chat->v2->services(env('TWILIO_CHAT_SERVICE_SID'))
                        ->channels
                        ->create([
                            'friendlyName' => 'chatroom',
                            'uniqueName' => 'chatroom',
                            'createdBy' => $user->username
                        ]);
        $twilio->chat->v2->services(env('TWILIO_CHAT_SERVICE_SID'))
            ->channels($channel->sid)
            ->members
            ->create($user->username, [
                'roleSid' => env('MIX_CHANNEL_ADMIN_ROLE_SID')
            ]);
        return $this->info('Channel initialized');
    }
public function handle ( ) { $ user = User :: create ( [ 'username' => 'mezie' , 'email' => 'chimezie@adonismastery.com' , 'password' => bcrypt ( 'password' ) ] ) ; $ twilio = new Client ( env ( 'TWILIO_AUTH_SID' ) , env ( 'TWILIO_AUTH_TOKEN' ) ) ; $ channel = $ twilio -> chat -> v2 -> services ( env ( 'TWILIO_CHAT_SERVICE_SID' ) ) -> channels -> create ( [ 'friendlyName' => 'chatroom' , 'uniqueName' => 'chatroom' , 'createdBy' => $ user -> username ] ) ; $ twilio -> chat -> v2 -> services ( env ( 'TWILIO_CHAT_SERVICE_SID' ) ) -> channels ( $ channel -> sid ) -> members -> create ( $ user -> username , [ 'roleSid' => env ( 'MIX_CHANNEL_ADMIN_ROLE_SID' ) ] ) ; return $ this -> info ( 'Channel initialized' ) ; }
Execute the console command.
Execute the console command .