diff --git a/app/Helpers/function.php b/app/Helpers/function.php index e0f0ed7..3d99365 100644 --- a/app/Helpers/function.php +++ b/app/Helpers/function.php @@ -43,8 +43,8 @@ function getOneCategory($categoryId, $return = '') * Notes: 获取文章分类详情 * @Author: 玄尘 * @Date : 2020/9/10 13:21 - * @param $categoryId - * @param string $result + * @param $categoryId + * @param string $result * @return \App\Models\Article */ function getOneArticleBYCate($categoryId, $result = '') @@ -73,11 +73,11 @@ function getOneArticleBYCate($categoryId, $result = '') * Notes: 获取分类下的文章 * @Author: 玄尘 * @Date : 2020/9/10 10:05 - * @param $categoryId - * @param int $take - * @param string $mark 显示多少当前分类还是当前分类+子分类 - * @param bool $hasCover - * @param string $order + * @param $categoryId + * @param int $take + * @param string $mark 显示多少当前分类还是当前分类+子分类 + * @param bool $hasCover + * @param string $order * @return \App\Models\Article */ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one', $hasCover = false, $order = 'desc') @@ -99,7 +99,7 @@ function getArticlesBYCate($categoryId, $take = 8, $mark = 'one', $hasCover = fa $articles = Article::where('status', 1) ->whereHas('categories', function ($q) use ($ids) { - $q->whereIN('id', $ids); + $q->whereIn('id', $ids); }) ->when($hasCover, function ($q) { $q->whereNotNull('cover'); @@ -162,13 +162,22 @@ function getAdvertsByCate($categoryId, $take = 8) ->get(); } +/** + * Notes: 根据分类id 获取文章 + * @Author: 玄尘 + * @Date : 2021/5/21 9:45 + * @param int $take + * @param false $hasCover + * @return mixed + */ function getArticlesByCateIds($take = 8, $hasCover = false) { + //分院新闻 媒体报道 科研动态 交流合作 党建文化 专题学习 $ids = [7, 17, 8, 5, 12, 30]; - $articles = Article::where('status', 1) + $articles = Article::query()->where('status', 1) ->whereHas('categories', function ($q) use ($ids) { - $q->whereIN('id', $ids); + $q->whereIn('id', $ids); }) ->latest() ->when($hasCover, function ($q) { diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index b89c962..e09dd4d 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -63,8 +63,8 @@