where($where)->order("add_time desc"); return $model; } /** * @return array */ public static function getChatList($uid, $to_uid, $mer_id, $page, $limit) { $data = self::setWhere($uid, $to_uid, $mer_id)->page($page, $limit)->select(); $data = count($data) > 0 ? $data->toArray() : []; foreach ($data as $key => &$item) { $user = StoreService::field("nickname,avatar")->where('mer_id', $mer_id)->where(array("uid" => $item["uid"]))->find(); if (!$user) $user = User::field("nickname,avatar")->where(array("uid" => $item["uid"]))->find(); $item["nickname"] = $user["nickname"]; $item["avatar"] = $user["avatar"]; $item["add_time"] = date('Y-m-d H:i:s',$item["add_time"]); } $count = self::setWhere($uid, $to_uid, $mer_id)->count(); return compact('data', 'count'); } }