正在显示
3 个修改的文件
包含
15 行增加
和
3 行删除
| @@ -56,7 +56,11 @@ class BlogController extends BaseController | @@ -56,7 +56,11 @@ class BlogController extends BaseController | ||
| 56 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | 56 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { |
| 57 | $str = []; | 57 | $str = []; |
| 58 | $this->getAllSub($this->map['category_id'],$str); | 58 | $this->getAllSub($this->map['category_id'],$str); |
| 59 | - $query = $query->whereIn('category_id',$str); | 59 | + $query->where(function ($subQuery) use ($str) { |
| 60 | + foreach ($str as $v) { | ||
| 61 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 62 | + } | ||
| 63 | + }); | ||
| 60 | } | 64 | } |
| 61 | if(isset($this->map['status'])){ | 65 | if(isset($this->map['status'])){ |
| 62 | $query = $query->where('status',$this->map['status']); | 66 | $query = $query->where('status',$this->map['status']); |
| @@ -59,7 +59,11 @@ class NewsController extends BaseController | @@ -59,7 +59,11 @@ class NewsController extends BaseController | ||
| 59 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | 59 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { |
| 60 | $str = []; | 60 | $str = []; |
| 61 | $this->getAllSub($this->map['category_id'],$str); | 61 | $this->getAllSub($this->map['category_id'],$str); |
| 62 | - $query = $query->whereIn('category_id',$str); | 62 | + $query->where(function ($subQuery) use ($str) { |
| 63 | + foreach ($str as $v) { | ||
| 64 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 65 | + } | ||
| 66 | + }); | ||
| 63 | } | 67 | } |
| 64 | if(isset($this->map['status'])){ | 68 | if(isset($this->map['status'])){ |
| 65 | $query = $query->where('status',$this->map['status']); | 69 | $query = $query->where('status',$this->map['status']); |
| @@ -80,7 +80,11 @@ class ProductController extends BaseController | @@ -80,7 +80,11 @@ class ProductController extends BaseController | ||
| 80 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | 80 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { |
| 81 | $str = []; | 81 | $str = []; |
| 82 | $this->getAllSub($this->map['category_id'],$str); | 82 | $this->getAllSub($this->map['category_id'],$str); |
| 83 | - $query = $query->whereIn('category_id',$str); | 83 | + $query->where(function ($subQuery) use ($str) { |
| 84 | + foreach ($str as $v) { | ||
| 85 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 86 | + } | ||
| 87 | + }); | ||
| 84 | } | 88 | } |
| 85 | if(isset($this->map['title']) && !empty($this->map['title'])){ | 89 | if(isset($this->map['title']) && !empty($this->map['title'])){ |
| 86 | $query = $query->where('title','like','%'.$this->map['title'].'%'); | 90 | $query = $query->where('title','like','%'.$this->map['title'].'%'); |
-
请 注册 或 登录 后发表评论