PHP code example of norris1z / admin_user_chat

1. Go to this page and download the library: Download norris1z/admin_user_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/ */

    

norris1z / admin_user_chat example snippets


'Norris1z\AdminUserChat\AdminUserChatServiceProvider::class',

sendMessageToUser, sendMessageToAllUsers, sendMessageToAdministrator, sendMessageToAllAdministrators

//User Controller 

public function message(Request $request,AdminUserChat $chat)
{
    $admin = User::where('is_admin',true)->first();
    
    //This sends a message to an administrator given the admin_id and message
    $chat->sendMessageToAdministrator(Auth::id(),$admin->id,$request->message);
    
     //This sends a message to all administrators given the admin_id and message
    $chat->sendMessageToAllAdministrators(Auth::id(),$admin->id,$request->message);
    
}

// Admin Controller

public function message(Request $request,AdminUserChat $chat)
{
    // This sends a message from the administrator to a user
    $chat->sendMessageToUser(Auth::id(),$request->user_id,$request->message);
    
    // This sends a message from the administrator to all users
    $chat->sendMessageToAllUsers(Auth::id(),$request->user_id,$request->message);
}
bash
php artisan vendor:publish
admin_user_chat.php
config.php
bash
php artisan migrate