This commit is contained in:
2022-07-04 16:09:41 +08:00
parent 35b7fbc9fa
commit 8c28733e02
2 changed files with 11 additions and 11 deletions

View File

@@ -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()

View File

@@ -20,7 +20,7 @@ trait ScopeStatus
*/
public function scopeShown($query)
{
return $query->where('status',1);
return $query->where('status', 1);
}
}