/** * 聊天窗口发送的信息 */ public function insertMsg() { if (AjaxRequest::ajax()) { $data = Input::all(); if (!$data['uid'] || !$data['chat_uid'] || !$data['content']) { $rstArr = ['error' => ['code' => -1, 'msg' => '数据有误!'], 'data' => []]; echo json_encode($rstArr); exit; } $msg = ['title' => '在线聊天', 'genre2' => 2, 'intro' => $data['content'], 'sender' => $data['uid'], 'senderTime' => time(), 'accept' => $data['chat_uid'], 'status' => 3, 'created_at' => time()]; MessageModel::create($msg); $rstArr = ['error' => ['code' => 0, 'msg' => '添加成功!']]; echo json_encode($rstArr); exit; } }
/** * 查询方法 */ public function query($del = 0) { $datas = MessageModel::where('del', $del)->paginate($this->limit); $datas->limit = $this->limit; return $datas; }
/** * 留言数量 */ public function messages() { return MessageModel::where('del', 0)->where('accept', $this->userid)->where('status', '>', 2)->get(); }
public function query($m = 1) { //$m:1收件箱,2发件箱,3草稿箱,4回收站 // //$t:0所有,1一天内,2一周内,3一月内,4更早 // $day = 3600*24; // $week = $day * 7; // $month = $week * 30; //假定一月30天 // if ($t==1) { $time = $day; } // elseif ($t==2) { $time = $week; } // elseif ($t==3) { $time = $month; } // elseif ($t==4) { $time = $month; } if ($m == 1) { $datas = MessageModel::where('del', 0)->where('sender', '<>', $this->userid)->where('accept', $this->userid)->where('status', '>', 2)->orderBy('id', 'desc')->paginate($this->limit); } elseif ($m == 2) { $datas = MessageModel::where('del', 0)->where('sender', $this->userid)->where('accept', '<>', $this->userid)->where('status', '>', 1)->orderBy('id', 'desc')->paginate($this->limit); } elseif ($m == 3) { $datas = MessageModel::where('del', 0)->where('sender', $this->userid)->where('accept', '<>', $this->userid)->where('status', 1)->orderBy('id', 'desc')->paginate($this->limit); } elseif ($m == 4) { $datas = MessageModel::where('del', 1)->orderBy('id', 'desc')->paginate($this->limit); } $datas->limit = $this->limit; return $datas; }
/** * 留言板,消息 */ public function messages() { return MessageModel::where('del', 0)->where('accept', $this->userid)->orderBy('id', 'desc')->paginate(2); }