|
|
@@ -3051,11 +3051,35 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (isset($data['category_id']) && !empty($data['category_id'])) {
|
|
|
array_push($where, ['category_id', '=', $data['category_id']]);
|
|
|
}
|
|
|
- $list = WebsiteCategory::query()->where($where)
|
|
|
+ if($data['article_id'] != 0){
|
|
|
+ $list = Article::where('article.id', $data['article_id'])
|
|
|
+ ->leftJoin('website_category', 'article.catid', '=', 'website_category.category_id')
|
|
|
+ // WebsiteCategory::query()->where($where)
|
|
|
+ ->leftJoin('website', 'website.id', '=', 'website_category.website_id')
|
|
|
+ ->leftJoin('article_ignore', 'website_category.website_id', '=', 'article_ignore.website_id') // 左连接 article_ignore 表
|
|
|
+ ->when(isset($data['article_id']), function ($query) use ($data) {
|
|
|
+ return $query->where(function ($query) use ($data) {
|
|
|
+ $query->where('article_ignore.article_id', $data['article_id'])
|
|
|
+ ->orWhereNull('article_ignore.article_id');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->select('website_category.*', 'website.website_name', 'article_ignore.c_show_time') // 选择需要的字段,不存在记录时 c_show_time 为 null
|
|
|
+ ->distinct()
|
|
|
+ ->get()
|
|
|
+ // ->array_map(function ($item) {
|
|
|
+ // $item['c_show_time'] = json_decode($item['category_arr_id'], true);
|
|
|
+ // return $item;
|
|
|
+ // })
|
|
|
+ ;
|
|
|
+ }else{
|
|
|
+ $list = WebsiteCategory::query()->where($where)
|
|
|
->leftJoin('website', 'website.id', '=', 'website_category.website_id')
|
|
|
->select('website_category.*', 'website.website_name')
|
|
|
->distinct()
|
|
|
->get();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (empty($list)) {
|
|
|
return Result::error("获取失败", 0);
|
|
|
} else {
|