where('session_id', $data['id']) ->where('message_type', '<>', 3) ->where('sender_identity', 1) ->count('id'); } public function getCsrMessageCountAttr($value, $data) { return \think\Db::name('kefu_record') ->where('session_id', $data['id']) ->where('sender_identity', 0) ->count('id'); } public function kefuuser() { return $this->belongsTo('KeFuUser', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function csr() { return $this->belongsTo('Admin', 'csr_id', 'id', [], 'LEFT')->setEagerlyType(0); } }