|
@@ -1293,25 +1293,29 @@ class NewsService implements NewsServiceInterface
|
|
|
];
|
|
|
// 查询栏目名称
|
|
|
$category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id']);
|
|
|
-
|
|
|
- // 查询图片新闻
|
|
|
- $imgArticles = Article::where('catid', $parentCatId)
|
|
|
+ if(empty($category)){
|
|
|
+ $imgArticles = [];
|
|
|
+ $textArticles = [];
|
|
|
+ // return Result::error("暂无此栏目",0);
|
|
|
+ }else{
|
|
|
+ // 查询图片新闻
|
|
|
+ $imgArticles = Article::where('catid', $parentCatId)
|
|
|
->where('imgurl', '!=', '')
|
|
|
// ->where($website)
|
|
|
->limit($parentImgNum)
|
|
|
- ->get();
|
|
|
-
|
|
|
- // 查询文字新闻
|
|
|
- $textArticles = Article::where('catid', $parentCatId)
|
|
|
- // ->where($website)
|
|
|
- ->limit($parentTextNum)
|
|
|
- ->get();
|
|
|
+ ->get()->all();
|
|
|
|
|
|
+ // 查询文字新闻
|
|
|
+ $textArticles = Article::where('catid', $parentCatId)
|
|
|
+ // ->where($website)
|
|
|
+ ->limit($parentTextNum)
|
|
|
+ ->get()->all();
|
|
|
+ }
|
|
|
$resultItem = [
|
|
|
'alias' => $category ? $category->alias : null,
|
|
|
'category_id' => $parentCatId,
|
|
|
- 'imgnum' => $imgArticles->toArray(),
|
|
|
- 'textnum' => $textArticles->toArray()
|
|
|
+ 'imgnum' => $imgArticles,
|
|
|
+ 'textnum' => $textArticles
|
|
|
];
|
|
|
|
|
|
if (!empty($item['child']) && $item['child'] != "") {
|
|
@@ -1322,25 +1326,30 @@ class NewsService implements NewsServiceInterface
|
|
|
|
|
|
// 查询子栏目名称
|
|
|
$childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)->first(['alias', 'category_id']);
|
|
|
-
|
|
|
- // 查询子栏目图片新闻
|
|
|
- $childImgArticles = Article::where('catid', $childCatId)
|
|
|
+ if(empty($childCategoryInfo)){
|
|
|
+ $childImgArticles = [];
|
|
|
+ $childTextArticles = [];
|
|
|
+ }else{
|
|
|
+ // 查询子栏目图片新闻
|
|
|
+ $childImgArticles = Article::where('catid', $childCatId)
|
|
|
->where('imgurl', '!=', '')
|
|
|
// ->where($website)
|
|
|
->limit($childImgNum)
|
|
|
- ->get();
|
|
|
+ ->get()->all();
|
|
|
|
|
|
- // 查询子栏目文字新闻
|
|
|
- $childTextArticles = Article::where('catid', $childCatId)
|
|
|
- // ->where($website)
|
|
|
- ->limit($childTextNum)
|
|
|
- ->get();
|
|
|
+ // 查询子栏目文字新闻
|
|
|
+ $childTextArticles = Article::where('catid', $childCatId)
|
|
|
+ // ->where($website)
|
|
|
+ ->limit($childTextNum)
|
|
|
+ ->get()->all();
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
$resultItem['child'] = [
|
|
|
'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
|
|
|
'category_id' => $childCatId,
|
|
|
- 'imgnum' => $childImgArticles->toArray(),
|
|
|
- 'textnum' => $childTextArticles->toArray()
|
|
|
+ 'imgnum' => $childImgArticles,
|
|
|
+ 'textnum' => $childTextArticles
|
|
|
];
|
|
|
}
|
|
|
}
|