PHP code example of nattaponra / chatkun

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

    

nattaponra / chatkun example snippets


 'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
         .
         .
         .
         .
         nattaponra\chatkun\ChatKunServiceProvider::class,
        
 

    $user1 = User::find(1);
    $user2 = User::find(2);

    $room  = ChatKun::createRoom("Our Room");

    ChatKun::addMember($user1,$room);
    ChatKun::addMember($user2,$room);


    ChatKun::send($user1,$room,"message","hi!! user2");
    ChatKun::send($user2,$room,"message","hi!! user1");
    ChatKun::send($user1,$room,"image","http://pwtthemes.com/demo/hannari/wp-content/uploads/2013/03/unicorn-wallpaper.jpg");

     $results = ChatKun::history(1,10);

     foreach ($results as $result){
         
         if($result->message_type == "image"){
             echo "User:".$result->user_id." Say that <img src='$result->message_content'><br>";
             
         }else{
             echo "User:".$result->user_id." Say that ".$result->message_content."<br>";
         }
     }

php artisan vendor:publish --provider=ChatKunServiceProvider