|
@@ -2088,7 +2088,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * 获取父级/子级栏目
|
|
|
|
|
|
+ * 获取父级/子级栏目------路由
|
|
* @param array $data
|
|
* @param array $data
|
|
* @return array
|
|
* @return array
|
|
* */
|
|
* */
|
|
@@ -2105,14 +2105,17 @@ class WebsiteService implements WebsiteServiceInterface
|
|
// 因此,需要先调用 `get()` 方法获取查询结果集合,再使用 `map` 方法进行处理。
|
|
// 因此,需要先调用 `get()` 方法获取查询结果集合,再使用 `map` 方法进行处理。
|
|
$category['parent'] = WebsiteCategory::where('website_id', $data['website_id'])
|
|
$category['parent'] = WebsiteCategory::where('website_id', $data['website_id'])
|
|
->where('pid', 0)
|
|
->where('pid', 0)
|
|
- ->select('alias_pinyin', 'category_id', 'alias')
|
|
|
|
|
|
+ ->select('aLIas_pinyin', 'category_id', 'alias')
|
|
->get() // 添加 get() 方法获取结果集合
|
|
->get() // 添加 get() 方法获取结果集合
|
|
->map(function ($item) {
|
|
->map(function ($item) {
|
|
- return [
|
|
|
|
- 'path' => "/{$item->alias_pinyin}/",
|
|
|
|
|
|
+ $result = [
|
|
'name' => $item->alias,
|
|
'name' => $item->alias,
|
|
'cid' => $item->category_id
|
|
'cid' => $item->category_id
|
|
];
|
|
];
|
|
|
|
+ if (!empty($item->aLIas_pinyin)) {
|
|
|
|
+ $result['path'] = "/{$item->aLIas_pinyin}/";
|
|
|
|
+ }
|
|
|
|
+ return $result;
|
|
})
|
|
})
|
|
->values()
|
|
->values()
|
|
->all();
|
|
->all();
|
|
@@ -2130,11 +2133,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
->where('category_id', $item->pid)
|
|
->where('category_id', $item->pid)
|
|
->first();
|
|
->first();
|
|
$parentAlias = $parent ? $parent->aLIas_pinyin : '';
|
|
$parentAlias = $parent ? $parent->aLIas_pinyin : '';
|
|
- return [
|
|
|
|
- 'path' => "/{$parentAlias}/{$alias_pinyin}/",
|
|
|
|
- 'name' => $alias ? "{$alias}" : null,
|
|
|
|
- 'cid' => $category_id ? "{$category_id}" : null
|
|
|
|
|
|
+ $result = [
|
|
|
|
+ 'name' => $alias,
|
|
|
|
+ 'cid' => $category_id
|
|
];
|
|
];
|
|
|
|
+ if (!empty($alias_pinyin) && !empty($parentAlias)) {
|
|
|
|
+ $result['path'] = "/{$parentAlias}/{$alias_pinyin}/";
|
|
|
|
+ }
|
|
|
|
+ return $result;
|
|
})->values()->all();
|
|
})->values()->all();
|
|
// }else if($data['id'] == 2){
|
|
// }else if($data['id'] == 2){
|
|
$foot = FooterCategory::where('website_id', $data['website_id'])
|
|
$foot = FooterCategory::where('website_id', $data['website_id'])
|
|
@@ -2143,11 +2149,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
$name = $item->name;
|
|
$name = $item->name;
|
|
$id = $item->id;
|
|
$id = $item->id;
|
|
$alias_pinyin = $item->name_pinyin;
|
|
$alias_pinyin = $item->name_pinyin;
|
|
- return [
|
|
|
|
- 'path' => "/{$alias_pinyin}/",
|
|
|
|
- 'name' => $name ? "{$name}" : null,
|
|
|
|
- 'cid' => $id ? "{$id}" : null
|
|
|
|
|
|
+ $result = [
|
|
|
|
+ 'name' => $name,
|
|
|
|
+ 'cid' => $id
|
|
];
|
|
];
|
|
|
|
+ if (!empty($item->name_pinyin)) {
|
|
|
|
+ $result['path'] = "/{$item->name_pinyin}/";
|
|
|
|
+ }
|
|
|
|
+ return $result;
|
|
})->values()->all();
|
|
})->values()->all();
|
|
// }else{
|
|
// }else{
|
|
// return Result::error("请输入正确的id", 0);
|
|
// return Result::error("请输入正确的id", 0);
|