'文本', self::TYPE_IMAGE => '图片', self::TYPE_VOICE => '语音', ]; return $status[$data['message_type']] ?? '未知'; } /** * 获取发送者类型文本 * @param $value * @param $data * @return string */ public function getSenderTypeTextAttr($value, $data) { $status = [ self::SENDER_USER => '用户', self::SENDER_TECH => '技师', ]; return $status[$data['sender_type']] ?? '未知'; } /** * 获取读取状态文本 * @param $value * @param $data * @return string */ public function getReadStatusTextAttr($value, $data) { $status = [ self::UNREAD => '未读', self::READ => '已读', ]; return $status[$data['read_status']] ?? '未知'; } /** * 关联会话 */ public function conversation() { return $this->belongsTo('app\common\model\chat\ChatConversation', 'conversation_id'); } /** * 关联订单 */ public function order() { return $this->belongsTo('app\common\model\order\Order', 'order_id'); } }