正在显示
2 个修改的文件
包含
12 行增加
和
2 行删除
| @@ -47,7 +47,7 @@ class ProductController extends BaseController | @@ -47,7 +47,7 @@ class ProductController extends BaseController | ||
| 47 | ]); | 47 | ]); |
| 48 | $data = $logic->getInfo($this->param['id']); | 48 | $data = $logic->getInfo($this->param['id']); |
| 49 | return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content', | 49 | return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content', |
| 50 | - 'describe', 'seo_mate', 'related_product_id', 'status'])); | 50 | + 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text'])); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | public function save(ProductRequest $request, ProductLogic $logic) | 53 | public function save(ProductRequest $request, ProductLogic $logic) |
| @@ -31,11 +31,21 @@ class ProductLogic extends BaseLogic | @@ -31,11 +31,21 @@ class ProductLogic extends BaseLogic | ||
| 31 | foreach ($v['category_id'] as $category_id){ | 31 | foreach ($v['category_id'] as $category_id){ |
| 32 | $v['category_id_text'][] =(new CategoryLogic())->getCacheInfo($category_id)['title']??''; | 32 | $v['category_id_text'][] =(new CategoryLogic())->getCacheInfo($category_id)['title']??''; |
| 33 | } | 33 | } |
| 34 | - $v['category_id_text'] = array_filter($v['category_id_text']); | 34 | + $v['category_id_text'] = Arr::arrToSet($v['category_id_text'], 'trim'); |
| 35 | } | 35 | } |
| 36 | return $this->success($data); | 36 | return $this->success($data); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | + public function getInfo($id) | ||
| 40 | + { | ||
| 41 | + $info = parent::getInfo($id); | ||
| 42 | + foreach ($info['category_id'] as $category_id) { | ||
| 43 | + $info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? ''; | ||
| 44 | + } | ||
| 45 | + $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim'); | ||
| 46 | + return $this->success($info); | ||
| 47 | + } | ||
| 48 | + | ||
| 39 | public function save($param){ | 49 | public function save($param){ |
| 40 | //封面取第一个图片 | 50 | //封面取第一个图片 |
| 41 | $param['thumb'] = $param['gallery'][0] ?? ''; | 51 | $param['thumb'] = $param['gallery'][0] ?? ''; |
-
请 注册 或 登录 后发表评论