Exemplo n.º 1
0
 public function run()
 {
     if (!Yii::$app->user->isGuest) {
         $currentUser = Yii::$app->user->identity;
         $chatUser = ChatUser::findOne($currentUser->id);
         $users = ChatUser::getAll($currentUser->id);
         return $this->render('chat', compact('users', 'chatUser'));
     } else {
         return '';
     }
     //        return Html::encode($this->message);
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRecipient()
 {
     return $this->hasOne(ChatUser::className(), ['id' => 'recipient_id']);
 }
Exemplo n.º 3
0
 public function actionGetTalkUnreadMessageCount()
 {
     $sender = $_POST['sender'];
     $chatUser = ChatUser::findOne(Yii::$app->user->identity->id);
     $count = $chatUser->getMessageCount($sender);
     return json_encode(['count' => $count]);
 }
Exemplo n.º 4
0
 public function getAllUsers()
 {
     $users = ChatUser::find()->where('id <> :id', ['id' => $this->id])->all();
     return $users;
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(ChatUser::className(), ['id' => 'user_id']);
 }