| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace App\Models;
- use Illuminate\Support\Facades\DB;
- class MessageRead extends BaseModel
- {
- protected $table = "message_read";
- public $timestamps = false;
- function getlist($id)
- {
- $data = $this->where('account_identity', $id)->get();
- if (!$data) {
- return -4010010022; //没有数据
- }
- return $data->toArray();
- }
- //添加消息数据
- function addMessage($data)
- {
- $res = $this->insert($data);
- if (!$res) {
- return -6030001222;
- }
- return 1;
- }
- //查询消息
- function Messagelist($id, $admin_id)
- {
- $data = $this->where('message_id', $id)->where('account_identity', $admin_id)->first();
- if (!$data) {
- return -4010010022; //没有数据
- }
- return 1;
- }
- function updateMsg($id, $admin_id, $data)
- {
- $res = $this->where('message_id', $id)->where('account_identity', $admin_id)->update($data);
- if (!$res) {
- return -4010011122;
- }
- return 1;
- }
- //统计某个管理员的未读信息
- function countNoReade($id)
- {
- $sql = "SELECT count(*) as num FROM message WHERE type=4 and id not in( SELECT message_id from message_read WHERE account_identity = '" . $id . "' GROUP BY message_id)";
- $num=DB::select($sql);
- // var_dump($num);die;
- return $num[0]->num;
- }
- }
|