|
|
@ -36,10 +36,24 @@ class Category extends Common |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function goodsList() { |
|
|
|
public function goodsList() { |
|
|
|
$category = CategoryModel::where('parent_id', 0)->normal()->order('weigh', 'desc')->order('id', 'desc')->select(); |
|
|
|
$category = CategoryModel::where('parent_id', 0)->normal()->order('weigh', 'desc')->order('id', 'desc')->select(); |
|
|
|
foreach ($category as &$item) { |
|
|
|
$category_ids = []; |
|
|
|
$item['goods_list'] = Goods::where('category_ids', 'in', $item['id'])->show()->select(); |
|
|
|
foreach ($category as $item) { |
|
|
|
|
|
|
|
$categories = CategoryModel::where('parent_id', $item['id'])->column('id'); |
|
|
|
|
|
|
|
$category_ids = array_merge($category_ids, $categories); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$category = CategoryModel::where('id', 'in', $category_ids)->normal()->order('weigh', 'desc')->order('id', 'desc')->select(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($category as &$row) { |
|
|
|
|
|
|
|
$row['image'] = formatImage($row['image']); |
|
|
|
|
|
|
|
$row['goods_list'] = Goods::where('category_ids', 'in', $row['id'])->show()->select(); |
|
|
|
|
|
|
|
foreach ($row['goods_list'] as $v) { |
|
|
|
|
|
|
|
$v->image = formatImage($v->image); |
|
|
|
|
|
|
|
$v->images = array_map('formatImage', $v->images); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->success('商城分类', $category); |
|
|
|
$this->success('商城分类', $category); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|