|
@@ -8,6 +8,7 @@ use App\Helper\Arr; |
|
@@ -8,6 +8,7 @@ use App\Helper\Arr; |
|
8
|
use App\Http\Controllers\Bside\BaseController;
|
8
|
use App\Http\Controllers\Bside\BaseController;
|
|
9
|
use App\Http\Logic\Bside\Product\ProductLogic;
|
9
|
use App\Http\Logic\Bside\Product\ProductLogic;
|
|
10
|
use App\Http\Requests\Bside\Product\ProductRequest;
|
10
|
use App\Http\Requests\Bside\Product\ProductRequest;
|
|
|
|
11
|
+use App\Models\Product\CategoryRelated;
|
|
11
|
use App\Rules\Ids;
|
12
|
use App\Rules\Ids;
|
|
12
|
use Illuminate\Http\Request;
|
13
|
use Illuminate\Http\Request;
|
|
13
|
|
14
|
|
|
@@ -26,9 +27,13 @@ class ProductController extends BaseController |
|
@@ -26,9 +27,13 @@ class ProductController extends BaseController |
|
26
|
if(!empty($this->param['search'])){
|
27
|
if(!empty($this->param['search'])){
|
|
27
|
$map[] = ['title', 'like', "%{$this->param['search']}%"];
|
28
|
$map[] = ['title', 'like', "%{$this->param['search']}%"];
|
|
28
|
}
|
29
|
}
|
|
29
|
- if(!empty($this->param['created_at'])){
|
30
|
+ if(!empty($this->param['created_at'][0]) && !empty($this->param['created_at'][1])){
|
|
30
|
$map[] = ['created_at', 'between', $this->param['created_at']];
|
31
|
$map[] = ['created_at', 'between', $this->param['created_at']];
|
|
31
|
}
|
32
|
}
|
|
|
|
33
|
+ if(!empty($this->param['category_id'])){
|
|
|
|
34
|
+ $ids = CategoryRelated::where('cate_id', $this->param['category_id'])->pluck('product_id')->toArray();
|
|
|
|
35
|
+ $map[] = ['id', 'in', $ids];
|
|
|
|
36
|
+ }
|
|
32
|
$sort = ['id' => 'desc'];
|
37
|
$sort = ['id' => 'desc'];
|
|
33
|
$data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_at', 'updated_at']);
|
38
|
$data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_at', 'updated_at']);
|
|
34
|
return $this->success($data);
|
39
|
return $this->success($data);
|