where($where) ->count(); $list = (new SystemArticleModel()) ->where($where) ->withAttr('type', function ($val, $data) { return config('type.article')[$val] ? config('type.article')[$val] : '未知类型'; }) ->page($page, $limit) ->order($sort) ->select(); return [$count, $list]; } public static function add($row) { $row['banner_desc'] = htmlspecialchars_decode($row['banner_desc']); $row['create_time'] = sr_getcurtime(time()); unset($row['file']); $type_info = SystemArticle::getById($row['type']); if ($type_info) { $count = SystemArticle::count($row['type']); if ($count >= $type_info['max_count']) { return [false, '这种类型只能存在' . $type_info['max_count'] . '种']; } } return (new SystemArticleModel())->insert($row); } }