|
@@ -2051,10 +2051,10 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (empty($website)) {
|
|
|
return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
- if ($data['id'] == 0) {
|
|
|
+ // if ($data['id'] == 0) {
|
|
|
// 在 Hyperf 中,查询构建器(Builder)没有 `map` 方法,`map` 方法是集合(Collection)的方法。
|
|
|
// 因此,需要先调用 `get()` 方法获取查询结果集合,再使用 `map` 方法进行处理。
|
|
|
- $category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ $category['parent'] = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
->where('pid', 0)
|
|
|
->select('alias_pinyin', 'category_id', 'alias')
|
|
|
->get() // 添加 get() 方法获取结果集合
|
|
@@ -2067,12 +2067,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
})
|
|
|
->values()
|
|
|
->all();
|
|
|
- } else {
|
|
|
+ // } else if($data['id'] == 1){
|
|
|
// 不使用 with 方法,直接查询父级栏目需要的字段
|
|
|
- $category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ $child = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
->where('pid', '!=', 0)
|
|
|
->get();
|
|
|
- $category = $category->map(function ($item) {
|
|
|
+ $category['child'] = $child->map(function ($item) {
|
|
|
$alias = $item->alias;
|
|
|
$category_id = $item->category_id;
|
|
|
$alias_pinyin = $item->aLIas_pinyin;
|
|
@@ -2087,7 +2087,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
'cid' => $category_id ? "{$category_id}" : null
|
|
|
];
|
|
|
})->values()->all();
|
|
|
- }
|
|
|
+ // }else if($data['id'] == 2){
|
|
|
+ $foot = FooterCategory::where('website_id', $data['website_id'])
|
|
|
+ ->get();
|
|
|
+ $category['foot'] = $foot->map(function ($item) {
|
|
|
+ $name = $item->name;
|
|
|
+ $id = $item->id;
|
|
|
+ $alias_pinyin = $item->name_pinyin;
|
|
|
+ return [
|
|
|
+ 'path' => "/{$alias_pinyin}/",
|
|
|
+ 'name' => $name ? "{$name}" : null,
|
|
|
+ 'cid' => $id ? "{$id}" : null
|
|
|
+ ];
|
|
|
+ })->values()->all();
|
|
|
+ // }else{
|
|
|
+ // return Result::error("请输入正确的id", 0);
|
|
|
+ // }
|
|
|
if (empty($category)) {
|
|
|
return Result::error("暂无此导航", 0);
|
|
|
}
|