调整首页

This commit is contained in:
2021-03-30 09:44:14 +08:00
parent e19ccdde87
commit e7a7b9b690
3 changed files with 24 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ class IndexController extends AdminController
return $grid;
}
public function form()
public function form(): Form
{
$form = new Form(new Article);
@@ -71,6 +71,7 @@ class IndexController extends AdminController
'on' => ['value' => 1, 'text' => '打开', 'color' => 'success'],
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
];
$form->datetime('created_at', '发布时间');
$form->switch('status', '状态')->states($states)->default(1);

View File

@@ -153,3 +153,20 @@ function getAdvertsByCate($categoryId, $take = 8)
->get();
}
function getArticlesByCateIds($take = 8, $hasCover = false)
{
$ids = [7, 17, 8, 5, 12, 30];
$articles = Article::whereIn('category_id', $ids)
->where('status', 1)
->latest()
->when($hasCover, function ($q) {
$q->whereNotNull('cover');
})
->take($take)
->get();
return $articles;
}