作者 赵彬吉

update

... ... @@ -47,7 +47,7 @@ class ProductController extends BaseController
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content',
'describe', 'seo_mate', 'related_product_id', 'status']));
'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text']));
}
public function save(ProductRequest $request, ProductLogic $logic)
... ...
... ... @@ -31,11 +31,21 @@ class ProductLogic extends BaseLogic
foreach ($v['category_id'] as $category_id){
$v['category_id_text'][] =(new CategoryLogic())->getCacheInfo($category_id)['title']??'';
}
$v['category_id_text'] = array_filter($v['category_id_text']);
$v['category_id_text'] = Arr::arrToSet($v['category_id_text'], 'trim');
}
return $this->success($data);
}
public function getInfo($id)
{
$info = parent::getInfo($id);
foreach ($info['category_id'] as $category_id) {
$info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? '';
}
$info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim');
return $this->success($info);
}
public function save($param){
//封面取第一个图片
$param['thumb'] = $param['gallery'][0] ?? '';
... ...