From 3e1092daabad4fce8621fa6a162d826010cf042c Mon Sep 17 00:00:00 2001 From: toogee Date: Wed, 15 Jan 2020 11:45:41 +0800 Subject: [PATCH] top/hot --- app/index/controller/Article.php | 10 +++++----- app/index/controller/Index.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 1e195c4..e87c8e2 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -33,9 +33,9 @@ class Article extends BaseController $where = true; } switch ($types) { - //查询文章,10个分1页 + //查询文章,15个分1页 case 'all': - $artList = ArticleModel::field('id,title,cate_id,user_id,create_time')->with([ + $artList = ArticleModel::field('id,title,cate_id,user_id,create_time,is_top,is_hot')->with([ 'cate' => function($query){ $query->where('delete_time',0)->field('id,catename'); }, @@ -46,7 +46,7 @@ class Article extends BaseController break; case 'hot': - $artList = ArticleModel::field('id,title,cate_id,user_id,create_time')->with([ + $artList = ArticleModel::field('id,title,cate_id,user_id,create_time,is_top,is_hot')->with([ 'cate' => function($query){ $query->where('delete_time',0)->field('id,catename'); }, @@ -57,7 +57,7 @@ class Article extends BaseController break; case 'top': - $artList = ArticleModel::field('id,title,cate_id,user_id,create_time')->with([ + $artList = ArticleModel::field('id,title,cate_id,user_id,create_time,is_top,is_hot')->with([ 'cate' => function($query){ $query->where('delete_time',0)->field('id,catename'); }, @@ -68,7 +68,7 @@ class Article extends BaseController break; default: - $artList = ArticleModel::field('id,title,cate_id,user_id,create_time')->with([ + $artList = ArticleModel::field('id,title,cate_id,user_id,create_time,is_top,is_hot')->with([ 'cate' => function($query){ $query->where('delete_time',0)->field('id,catename'); }, diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index ce5d6f1..45fa9a9 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -23,7 +23,7 @@ class Index extends BaseController $sliders = Db::name('slider')->where('slid_status',1)->where('delete_time',0)->where('slid_type',1)->whereTime('slid_over','>=',time())->select(); //置顶文章 - $artTop = Article::field('id,title,cate_id,user_id,create_time')->where(['is_top'=>1,'status'=>1,'delete_time'=>0])->with([ + $artTop = Article::field('id,title,cate_id,user_id,create_time,is_top')->where(['is_top'=>1,'status'=>1,'delete_time'=>0])->with([ 'cate' => function($query){ $query->where('delete_time',0)->field('id,catename'); }, @@ -33,7 +33,7 @@ class Index extends BaseController ])->withCount(['comments'])->order('create_time','desc')->limit(5)->withCache(30)->select(); //首页文章显示15条 - $artList = Article::field('id,title,cate_id,user_id,create_time')->with([ + $artList = Article::field('id,title,cate_id,user_id,create_time,is_hot')->with([ 'cate' => function($query){ $query->where('delete_time',0)->field('id,catename'); },