diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index f487981..741c066 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -24,54 +24,54 @@ class IndexController extends Controller $dzjsCate = Category::find(28);//党政建设 $xxydCate = Category::find(9);//学习园地 - $notices = Article::query() + $notices = Article::shown() ->ByCategory(6) ->bysort() ->take(2) ->get();//两个通知公告 - $mtbdArticles = Article::query() + $mtbdArticles = Article::shown() ->byCategory(31) ->bysort() ->take(2) ->get(); - $nyydtimg = Article::query() + $nyydtimg = Article::shown() ->byCategory(7) ->whereNotNull('cover') ->bysort() ->take(2) ->get(); - $nyydt = Article::query() + $nyydt = Article::shown() ->whereNotIn('id', $nyydtimg->pluck('id')) ->byCategory(7) ->bysort() ->take(4) ->get(); - $dzjsimg = Article::query() + $dzjsimg = Article::shown() ->byCategory($dzjsCate->id) ->whereNotNull('cover') ->bysort() ->first(); - $dzjsArticles = Article::query() + $dzjsArticles = Article::shown() ->where('id', '<>', $dzjsimg->id) ->byCategory($dzjsCate->id) ->bysort() ->take(6) ->get(); - $xxydimg = Article::query() + $xxydimg = Article::shown() ->byCategory($xxydCate->id) ->whereNotNull('cover') ->bysort() ->first(); - $xxydArticles = Article::query() + $xxydArticles = Article::shown() ->where('id', '<>', $xxydimg->id) ->byCategory($xxydCate->id) ->bysort() @@ -82,13 +82,13 @@ class IndexController extends Controller $categorys = Category::oldest('order')->find([20, 21, 24]);//成果 $categorys = $categorys->map(function ($info) { - $imgArticle = Article::query() + $imgArticle = Article::shown() ->byCategory($info->id) ->whereNotNull('cover') ->bysort() ->first(); $info->imgArticle = $imgArticle; - $info->articleLists = Article::query() + $info->articleLists = Article::shown() ->where('id', '<>', $imgArticle->id) ->byCategory($info->id) ->bysort() diff --git a/app/Models/Traits/ScopeStatus.php b/app/Models/Traits/ScopeStatus.php index f526a8f..3c2171b 100644 --- a/app/Models/Traits/ScopeStatus.php +++ b/app/Models/Traits/ScopeStatus.php @@ -20,7 +20,7 @@ trait ScopeStatus */ public function scopeShown($query) { - return $query->where('status',1); + return $query->where('status', 1); } }