sintret/yii2-chat-adminlte

Yii2 extension for Chat plugin with admin lte

Installs: 9 742

Dependents: 3

Suggesters: 0

Security: 0

Stars: 30

Watchers: 5

Forks: 33

Open Issues: 6

Type:yii2-extension

v1.0.0 2015-01-14 13:46 UTC

This package is not auto-updated.

Last update: 2021-01-18 15:49:48 UTC


README

yii2 chat widget widget admin lte

add via composer :

"sintret/yii2-chat-adminlte": "dev-master"

You just add table chat to your database with this :

CREATE TABLE `chat` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `userId` INT(11) DEFAULT NULL,
  `message` TEXT,
  `updateDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=INNODB;

and calling the widget in the view :

                                        
         \yii\helpers\Url::to(['/chat/send-chat']),
            'userModel'=>  \app\models\User::className(),
            'userField' => 'avatarImage'
                ]); ?>
    

in your controller eg ChatController action sendChat

public function actionSendChat() {
    if (!empty($_POST)) {
        echo \sintret\chat\ChatRoom::sendChat($_POST);
    }
}

attribute additional for this widget:

url : your controller/action to post message using ajax

userModel : your user model class name

userField : your avatar image source in your User class, ex: avatarImage