调整首页
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user