field('id,category_id,title,synopsis,author,image,sort') ->where(function ($query) use ($categoryId) { if ($categoryId) { $query->where('category_id', $categoryId); } }) ->order('sort desc,id desc') ->paginate($pageSize, false, ['page' => $page]); return $categoryList; } /** * 获取文章详情 * @param int $id 文章ID * @return array|bool|Model|string|\PDOStatement */ public static function getArticleInfo($id = 0) { $categoryInfo = self::where('id', $id) ->field('id,category_id,title,synopsis,author,image,sort,content') ->find(); return $categoryInfo; } }