self::NEW_MESSAGE], [['files'], 'string', 'max' => 255], [['chat_id'], 'exist', 'skipOnError' => true, 'targetClass' => Chat::className(), 'targetAttribute' => ['chat_id' => 'chat_id']], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'message_id' => Yii::t('app', 'message_id'), 'chat_id' => Yii::t('app', 'chat_id'), 'user_id' => Yii::t('app', 'user_id'), 'status' => Yii::t('app', 'status'), 'text' => Yii::t('app', 'text'), 'files' => Yii::t('app', 'files'), 'date' => Yii::t('app', 'date'), ]; } /** * @return \yii\db\ActiveQuery */ public function getChat() { return $this->hasOne(Chat::className(), ['chat_id' => 'chat_id']); } public function getUser() { return $this->hasOne(UserInfo::className(), ['user_id' => 'user_id']); } public function getFilesList(){ $files = json_decode($this->files); if(!empty($files)){ return File::findAll($files); } else { return false; } } public function isMy(){ if($this->user_id == \Yii::$app->user->id){ return true; } else { return false; } } }