Yii 2.0: yii2-chat-adminlte

Yii2 Chat Widget
2 followers

yii2-chat-adminlte

yii2 chat widget widget admin lte

Requirements

Yii2

Instalation

add via composer : "sintret/yii2-chat-adminlte": "dev-master"

Usage

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;

in your view, you must to setup url like the following...

<?= \sintret\chat\ChatRoom::widget(['url'=>  \yii\helpers\Url::to(['/chat/send-chat'])]); ?>;

in your controller,

public function actionSendChat() {
        $message = $_POST['message'];
        if ($message) {
            $model = new \sintret\chat\models\Chat;
            $model->message = $message;
            if ($model->save()) {
                echo \sintret\chat\ChatRoom::data();
            } else {
                print_r($model->getErrors());
                exit(0);
            }
        }
    }

Resources

external resources for this extension...

Be the first person to leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet