yii2-chat-adminlte Yii2 Chat Widget

yii2-chat-adminlte

  1. Requirements
  2. Instalation
  3. Usage
  4. Resources

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...

<?php
        echo \sintret\chat\ChatRoom::widget([
            'url' => \yii\helpers\Url::to(['/chat/send-chat']),
            'userModel'=>  \app\models\User::className(),
            'userField'=>'avatarImage'
            ]
        );
        ?>

in your controller,

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 attribute in your class user model, ex:avatarImage or you can make your virtual property in your class user like this following :

public class User extends blalala {

public function getAvatarImage(){
return Yii::getAlias($this->avatar);
}
}

Resources

external resources for this extension...

6 0
10 followers
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: User Interface
Tags: chat, jquery, yii2
Developed by: sintret
Created on: Jan 14, 2015
Last updated: 9 years ago

Related Extensions