From 59a7f8f9069d9ca77d52f58b6ce69ad223296a8d Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Mon, 20 Dec 2021 13:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Helpers/function.php | 22 +++++++++++++- resources/views/category/djwh.blade.php | 20 ++++++++----- resources/views/category/kxyj.blade.php | 40 +++++++++++++++++-------- 3 files changed, 60 insertions(+), 22 deletions(-) diff --git a/app/Helpers/function.php b/app/Helpers/function.php index 99e22cb..0d1e296 100644 --- a/app/Helpers/function.php +++ b/app/Helpers/function.php @@ -57,7 +57,7 @@ function getOneArticleBYCate($categoryId, $result = '') * @param int $recommen * @return \App\Models\Article */ -function getArticlesBYCate($categoryId, $take = 8, $recommen = 0) +function getArticlesBYCate($categoryId, int $take = 8, $recommen = 0) { $cate = Category::find($categoryId); $ids = $cate ? $cate->getAllChildrenId() : []; @@ -75,6 +75,26 @@ function getArticlesBYCate($categoryId, $take = 8, $recommen = 0) return $articles; } +/** + * Notes: 获取有图片的文章 + * + * @Author: 玄尘 + * @Date: 2021/12/20 13:22 + * @param $categoryId + * @param $take + * @return mixed + */ +function getHasCoverArticlesByCate($categoryId, $take = 8) +{ + return Article::where('status', 1) + ->ByCategory([$categoryId]) + ->whereNotNull('cover') + ->latest('sort') + ->latest() + ->take($take) + ->get(); +} + //获取子分类 function getCateChild($categoryId, $take = '') { diff --git a/resources/views/category/djwh.blade.php b/resources/views/category/djwh.blade.php index b1d5944..31913ca 100644 --- a/resources/views/category/djwh.blade.php +++ b/resources/views/category/djwh.blade.php @@ -21,11 +21,14 @@