PHP code example of doctopro / laravel-video-chat

1. Go to this page and download the library: Download doctopro/laravel-video-chat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

doctopro / laravel-video-chat example snippets


composer 

Wqqas1\LaravelVideoChat\LaravelVideoChatServiceProvider::class,
 
php artisan vendor:publish --provider="Wqqas1\LaravelVideoChat\LaravelVideoChatServiceProvider"
 
php artisan migrate
php artisan storage:link

change APP_URL in .env

return [
    'relation'  => [
        'conversations' =>  Wqqas1\LaravelVideoChat\Models\Conversation\Conversation::class,
        'group_conversations' => Wqqas1\LaravelVideoChat\Models\Group\Conversation\GroupConversation::class
    ],
    'user' => [
        'model' =>  App\User::class,
        'table' =>  'users' // Existing user table name
    ],
    'table' => [
        'conversations_table'   =>  'conversations',
        'messages_table'        =>  'messages',
        'group_conversations_table' =>  'group_conversations',
        'group_users_table'     =>  'group_users',
        'files_table'           =>  'files'
    ],
    'channel'   =>  [
        'new_conversation_created'  =>  'new-conversation-created',
        'chat_room'                 =>  'chat-room',
        'group_chat_room'           =>  'group-chat-room'
    ],
    'upload' => [
        'storage' => 'public'
    ]
];

$groups = Chat::getAllGroupConversations();
$conversations = Chat::getAllConversations()

Chat::startConversationWith($otherUserId);

Chat::acceptMessageRequest($conversationId);

$conversation = Chat::getConversationMessageById($conversationId);

Chat::sendConversationMessage($conversationId, $message);

Chat::startVideoCall($conversationId , $request->all());

Chat::createGroupConversation( $groupName , [ $otherUserId , $otherUserId2 ]);

$conversation = Chat::getGroupConversationMessageById($groupConversationId);

Chat::sendGroupConversationMessage($groupConversationId, $message);

Chat::addMembersToExistingGroupConversation($groupConversationId, [ $otherUserId , $otherUserId2 ])

Chat::removeMembersFromGroupConversation($groupConversationId, [ $otherUserId , $otherUserId2 ])

Chat::leaveFromGroupConversation($groupConversationId);

Chat::sendFilesInConversation($conversationId , $request->file('files'));

Chat::sendFilesInGroupConversation($groupConversationId , $request->file('files'));
blade
<ul class="list-group">
    @foreach($conversations as $conversation)
        <li class="list-group-item">
        @if($conversation->message->conversation->is_accepted)
            <a href="#">
                <h2>{{$conversation->user->name}}</h2>
                @if(!is_null($conversation->message))
                    <span>{{ substr($conversation->message->text, 0, 20)}}</span>
                @endif
            </a>
         @else
            <a href="#">
                <h2>{{$conversation->user->name}}</h2>
                @if($conversation->message->conversation->second_user_id == auth()->user()->id)
                    <a href="accept_request_route" class="btn btn-xs btn-success">
                        Accept Message Request
                    </a>
                @endif
            </a>
         @endif
        </li>
    @endforeach

    @foreach($groups as $group)
        <li class="list-group-item">
            <a href="#">
                <h2>{{$group->name}}</h2>
                <span>{{ $group->users_count }} Member</span>
            </a>
        </li>
    @endforeach
</ul>