yii2-chat-adminlte
yii2 chat widget widget admin lte
Yii2
add via composer : "sintret/yii2-chat-adminlte": "dev-master"
You just add table chat to your database with this :
CREATE TABLEchat
(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); } } }
external resources for this extension...
Be the first person to leave a comment
Please login to leave your comment.