From d0da1ef26945443c6fb0c5e4b0e472f3b25207db Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Fri, 14 Jan 2022 10:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A6=96=E9=A1=B5=E5=92=8C?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E9=A1=B5=E7=9A=84=E9=99=A2=E6=89=80=E6=96=B0?= =?UTF-8?q?=E9=97=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/CategoryController.php | 20 +++++++++++++++----- app/Http/Controllers/IndexController.php | 12 ++++++++---- resources/views/index/index.blade.php | 6 +++--- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 0021d1c..5fd731a 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Article; use App\Models\Category; class CategoryController extends Controller @@ -36,13 +37,22 @@ class CategoryController extends Controller $template = 'photos'; } } + //院所新闻 + if ($category->id == 66) { + $articles = Article::ByCategory([66, 67, 60, 61, 17, 26,]) + ->where('status', 1) + ->latest('sort') + ->latest('created_at') + ->paginate(); + } else { + $articles = $category->relations($category->type) + ->where('status', 1) + ->latest('sort') + ->latest('created_at') + ->paginate(); + } - $articles = $category->relations($category->type) - ->where('status', 1) - ->latest('sort') - ->latest('created_at') - ->paginate(); $parent = $category; if ($category->childrens->isEmpty() && $category->parent) { diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 31d0c50..c28ad0f 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -13,16 +13,20 @@ class IndexController extends Controller /** * Notes: 首页 + * * @Author: 玄尘 * @Date : 2020/6/1 9:11 */ public function index() { + $ysxw = Article::where('status', 1) + ->ByCategory([66, 67, 60, 61, 17, 26,]) + ->latest('sort') + ->latest() + ->take(7) + ->get(); - $top_adverts = Advert::where('category_id', 33)->latest('sort')->first(); - $cent_adverts = Advert::where('category_id', 33)->latest('sort')->first(); - - return view('index.index', compact('top_adverts', 'top_adverts')); + return view('index.index', compact('ysxw')); } public function search(Request $request) diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index 01783f1..8cf4b19 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -33,11 +33,11 @@