作者 lyh

gx

... ... @@ -115,9 +115,12 @@ class ProductController extends BaseController
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str[] = $this->map['category_id'];
$str = $this->getAllSub($this->map['category_id'],$str);
$productArr = CategoryRelated::whereIn('cate_id',$str)->pluck('product_id')->toArray();
$query->whereIn('id',$productArr);
$this->getAllSub($this->map['category_id'],$str);
$query->where(function ($subQuery) use ($str) {
foreach ($str as $v) {
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
}
});
}
if(isset($this->map['title']) && !empty($this->map['title'])){
$query = $query->where('title','like','%'.$this->map['title'].'%');
... ...