|
@@ -1189,15 +1189,21 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
//手动推荐文章
|
|
|
$commend_ids = $result['commend_id'] ? json_decode($result['commend_id']) : [];
|
|
|
- $commendArticle = Article::whereIn('article.id', $commend_ids)
|
|
|
- ->leftjoin('website_category', 'website_category.category_id', '=', 'article.catid')
|
|
|
- ->where('article.status', 1)
|
|
|
- ->where('website_category.website_id', $data['website_id'])
|
|
|
- ->select('article.id', 'article.title', 'article.catid', 'article.imgurl', 'article.hits', 'article.created_at', 'website_category.alias', 'website_category.alias_pinyin', 'website_category.website_id')
|
|
|
- ->orderByRaw("FIELD(article.id, " . implode(',', $commend_ids) . ")")
|
|
|
- // ->orderBy('article.updated_at', 'desc')
|
|
|
- ->limit(5)
|
|
|
- ->get();
|
|
|
+ if (empty($commend_ids)) {
|
|
|
+ $commendArticle = [];
|
|
|
+ } else {
|
|
|
+ //去除不存在的文章ID
|
|
|
+ $commendArticle = Article::whereIn('article.id', $commend_ids)
|
|
|
+ ->leftjoin('website_category', 'website_category.category_id', '=', 'article.catid')
|
|
|
+ ->where('article.status', 1)
|
|
|
+ ->where('website_category.website_id', $data['website_id'])
|
|
|
+ ->select('article.id', 'article.title', 'article.catid', 'article.imgurl', 'article.hits', 'article.created_at', 'website_category.alias', 'website_category.alias_pinyin', 'website_category.website_id')
|
|
|
+ ->orderByRaw("FIELD(article.id, " . implode(',', $commend_ids) . ")")
|
|
|
+ // ->orderBy('article.updated_at', 'desc')
|
|
|
+ ->limit(5)
|
|
|
+ ->get();
|
|
|
+ }
|
|
|
+
|
|
|
$result['category_id'] = $category['category_id'];
|
|
|
$result['cat_name'] = $category['alias'];
|
|
|
$result['website_name'] = $category['website_name'] ?? "";
|