This commit is contained in:
2021-12-21 13:31:06 +08:00
parent 03bd00c545
commit 4328cd3624
2 changed files with 10 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ class ArticleController extends Controller
public function index(Category $category)
{
$articles = Article::ByCategory($category->id)
->where('status', 1)
->orderBy('created_at', 'desc')
->paginate(5);

View File

@@ -19,16 +19,21 @@ class IndexController extends Controller
public function index()
{
$data = [
'ysxw' => Article::ByCategory(15)->latest('sort')->latest()->take(8)->get(),
'ysxw' => Article::ByCategory(15)
->where('status', 1)
->latest('sort')
->latest()
->take(8)
->get(),
// 'kjcg' => Article::where('category_id', 19)->latest('sort')->latest()->take(8)->get(),
// 'lwzl' => Patent::latest('sort')->latest()->take(11)->get(),
'center_advert' => Advert::latest('sort')->latest()->where('category_id', 23)->take(3)->get(),
'ysxw_right_advert' => Advert::latest('sort')->latest()->where('category_id', 24)->first(),
'kjcg_right_advert' => Advert::latest('sort')->latest()->where('category_id', 25)->take(2)->get(),
'lwzl_right_advert' => Advert::latest('sort')->latest()->where('category_id', 27)->take(2)->get(),
'pos_a' => Article::where('position', Article::POSITION_A)->first(),
'pos_b' => Article::where('position', Article::POSITION_B)->first(),
'pos_c' => Article::where('position', Article::POSITION_C)->first(),
'pos_a' => Article::where('position', Article::POSITION_A)->where('status', 1)->first(),
'pos_b' => Article::where('position', Article::POSITION_B)->where('status', 1)->first(),
'pos_c' => Article::where('position', Article::POSITION_C)->where('status', 1)->first(),
];
return view('index.index', $data);