Exemple #1
0
 /**
  * Get new message count
  * @param null|integer $dialogId
  * @return int|string
  */
 public function getNewCount($dialogId = null)
 {
     $query = $this->hasMany(PoprigunChatMessage::className(), ['dialog_id' => 'id'])->innerJoinWith('chatUserRel')->andWhere([PoprigunChatUserRel::tableName() . '.is_view' => PoprigunChatUserRel::NEW_MESSAGE]);
     if (null !== $dialogId) {
         $query->andWhere([PoprigunChatDialog::tableName() . '.id' => $dialogId]);
     }
     return $query->count();
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChat()
 {
     return $this->hasOne(PoprigunChatMessage::className(), ['id' => 'message_id']);
 }