正在显示
1 个修改的文件
包含
6 行增加
和
3 行删除
| @@ -115,9 +115,12 @@ class ProductController extends BaseController | @@ -115,9 +115,12 @@ class ProductController extends BaseController | ||
| 115 | $query = $query->where('project_id',$this->user['project_id']); | 115 | $query = $query->where('project_id',$this->user['project_id']); |
| 116 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { | 116 | if (isset($this->map['category_id']) && !empty($this->map['category_id'])) { |
| 117 | $str[] = $this->map['category_id']; | 117 | $str[] = $this->map['category_id']; |
| 118 | - $str = $this->getAllSub($this->map['category_id'],$str); | ||
| 119 | - $productArr = CategoryRelated::whereIn('cate_id',$str)->pluck('product_id')->toArray(); | ||
| 120 | - $query->whereIn('id',$productArr); | 118 | + $this->getAllSub($this->map['category_id'],$str); |
| 119 | + $query->where(function ($subQuery) use ($str) { | ||
| 120 | + foreach ($str as $v) { | ||
| 121 | + $subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]); | ||
| 122 | + } | ||
| 123 | + }); | ||
| 121 | } | 124 | } |
| 122 | if(isset($this->map['title']) && !empty($this->map['title'])){ | 125 | if(isset($this->map['title']) && !empty($this->map['title'])){ |
| 123 | $query = $query->where('title','like','%'.$this->map['title'].'%'); | 126 | $query = $query->where('title','like','%'.$this->map['title'].'%'); |
-
请 注册 或 登录 后发表评论