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' => 'Message ID', 'chat_id' => 'Chat ID', 'user_id' => 'User ID', 'status' => 'Status', 'text' => 'Сообщение', 'files' => 'Files', 'date' => '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; } } }