'提问', self::TYPE_SHARE => '分享', self::TYPE_DISCUSS => '讨论', self::TYPE_SUGGEST => '建议', self::TYPE_NOTICE => '公告', self::TYPE_DYNAMIC => '动态', ]; /** * 前台列表查询(返回普通集合,便于模板直接 volist) * @param int $boardId * @param string $type 空=全部 * @param string $order hot|new * @param int $size 返回条数 */ public static function listFront(int $boardId = 0, string $type = '', string $order = 'new', int $page = 1, int $size = 20) { $q = self::where('status', 1); if ($boardId > 0) { $q->where('board_id', $boardId); } if ($type !== '' && isset(self::$typeMap[(int) $type])) { $q->where('type', (int) $type); } if ($order === 'hot') { $q->order('reply_count desc, views desc'); } else { $q->order('is_top desc, id desc'); } return $q->limit($size)->select(); } public static function findById(int $id) { return self::where('id', $id)->where('status', '>=', 0)->find(); } public static function addViews(int $id) { self::where('id', $id)->inc('views', 1)->update(); } }