|
@@ -36,6 +36,38 @@ class CategoryController extends BaseController |
|
@@ -36,6 +36,38 @@ class CategoryController extends BaseController |
|
36
|
$filed = ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'];
|
36
|
$filed = ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'];
|
|
37
|
$list = $category->list($this->map,'id',$filed);
|
37
|
$list = $category->list($this->map,'id',$filed);
|
|
38
|
if(!empty($list)){
|
38
|
if(!empty($list)){
|
|
|
|
39
|
+ foreach ($list as $k =>$v){
|
|
|
|
40
|
+ $v = $this->handleParam($category,$v);
|
|
|
|
41
|
+ $list[$k] = $v;
|
|
|
|
42
|
+ }
|
|
|
|
43
|
+ $data = $this->getListSon($list);
|
|
|
|
44
|
+ }
|
|
|
|
45
|
+ return $this->response('success',Code::SUCCESS,$data);
|
|
|
|
46
|
+ }
|
|
|
|
47
|
+
|
|
|
|
48
|
+ /**
|
|
|
|
49
|
+ * @remark :分类处理参数
|
|
|
|
50
|
+ * @name :handleParam
|
|
|
|
51
|
+ * @author :lyh
|
|
|
|
52
|
+ * @method :post
|
|
|
|
53
|
+ * @time :2023/8/17 11:10
|
|
|
|
54
|
+ */
|
|
|
|
55
|
+ public function handleParam(&$category,$v){
|
|
|
|
56
|
+ $v['url'] = $this->user['domain'] . $v['route'] ;
|
|
|
|
57
|
+ $cate_ids = $category->getChildIdsArr($v['id']);
|
|
|
|
58
|
+ $v['product_num'] = CategoryRelated::whereIn('cate_id', $cate_ids)->distinct()->count('product_id');
|
|
|
|
59
|
+ $v['image_link'] = getImageUrl($v['image']);
|
|
|
|
60
|
+ return $v;
|
|
|
|
61
|
+ }
|
|
|
|
62
|
+
|
|
|
|
63
|
+ /**
|
|
|
|
64
|
+ * @remark :无分页子集处理
|
|
|
|
65
|
+ * @name :getListSon
|
|
|
|
66
|
+ * @author :lyh
|
|
|
|
67
|
+ * @method :post
|
|
|
|
68
|
+ * @time :2023/8/17 11:12
|
|
|
|
69
|
+ */
|
|
|
|
70
|
+ public function getListSon(&$list){
|
|
39
|
$data = array();
|
71
|
$data = array();
|
|
40
|
foreach ($list as $v){
|
72
|
foreach ($list as $v){
|
|
41
|
$v = (array)$v;
|
73
|
$v = (array)$v;
|
|
@@ -44,8 +76,7 @@ class CategoryController extends BaseController |
|
@@ -44,8 +76,7 @@ class CategoryController extends BaseController |
|
44
|
$data[] = $v;
|
76
|
$data[] = $v;
|
|
45
|
}
|
77
|
}
|
|
46
|
}
|
78
|
}
|
|
47
|
- }
|
|
|
|
48
|
- return $this->response('success',Code::SUCCESS,$data);
|
79
|
+ return $data;
|
|
49
|
}
|
80
|
}
|
|
50
|
|
81
|
|
|
51
|
public function info(Request $request, CategoryLogic $logic){
|
82
|
public function info(Request $request, CategoryLogic $logic){
|