|
@@ -2094,7 +2094,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
* 获取父级/子级栏目------路由
|
|
|
* @param array $data
|
|
|
* @return array
|
|
@@ -2108,45 +2108,46 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (empty($website)) {
|
|
|
return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $category['parent'] = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('pid', 0)
|
|
|
- ->selectRaw("category_id as cid, alias as name, CONCAT('/', '', aLIas_pinyin, '/') as path")
|
|
|
- ->get()
|
|
|
- ->all();
|
|
|
-
|
|
|
-
|
|
|
- $child = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('pid', '!=', 0)
|
|
|
- ->get();
|
|
|
- $category['child'] = $child->map(function ($item) {
|
|
|
- $alias = $item->alias;
|
|
|
- $category_id = $item->category_id;
|
|
|
- $alias_pinyin = $item->aLIas_pinyin;
|
|
|
-
|
|
|
- $parent = WebsiteCategory::where('website_id', $item->website_id)
|
|
|
- ->where('category_id', $item->pid)
|
|
|
- ->first();
|
|
|
- $parentAlias = $parent ? $parent->aLIas_pinyin : '';
|
|
|
- $result = [
|
|
|
- 'name' => $alias,
|
|
|
- 'cid' => $category_id
|
|
|
- ];
|
|
|
- if (!empty($alias_pinyin) && !empty($parentAlias)) {
|
|
|
- $result['path'] = "/{$parentAlias}/{$alias_pinyin}/";
|
|
|
- }
|
|
|
- return $result;
|
|
|
- })->values()->all();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ $category['parent'] = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->where('pid', 0)
|
|
|
+ ->selectRaw("category_id as cid, alias as name, CONCAT('/', '', aLIas_pinyin, '/') as path")
|
|
|
+ ->get()
|
|
|
+ ->all();
|
|
|
+
|
|
|
+
|
|
|
+ $parentCategories = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->where('pid', 0)
|
|
|
+ ->select('category_id', 'aLIas_pinyin')
|
|
|
+ ->get()
|
|
|
+ ->keyBy('category_id');
|
|
|
+
|
|
|
+
|
|
|
+ $child = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->where('pid', '!=', 0)
|
|
|
+ ->select('alias', 'category_id', 'aLIas_pinyin', 'pid')
|
|
|
+ ->get();
|
|
|
+
|
|
|
+
|
|
|
+ $category['child'] = $child->map(function ($item) use ($parentCategories) {
|
|
|
+ $alias = $item->alias;
|
|
|
+ $category_id = $item->category_id;
|
|
|
+ $alias_pinyin = $item->aLIas_pinyin;
|
|
|
+ $parent = $parentCategories->get($item->pid);
|
|
|
+ $parentAlias = $parent ? $parent->aLIas_pinyin : '';
|
|
|
+ $result = [
|
|
|
+ 'name' => $alias,
|
|
|
+ 'cid' => $category_id
|
|
|
+ ];
|
|
|
+ if (!empty($alias_pinyin) && !empty($parentAlias)) {
|
|
|
+ $result['path'] = "/{$parentAlias}/{$alias_pinyin}/";
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
+ })->values()->all();
|
|
|
if (empty($category)) {
|
|
|
return Result::error("暂无此导航", 0);
|
|
|
}
|
|
|
-
|
|
|
return Result::success($category);
|
|
|
}
|
|
|
|