|
@@ -635,10 +635,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
->select('pid', 'category_id', 'alias');
|
|
->select('pid', 'category_id', 'alias');
|
|
|
$pid = $pidQuery->pluck('pid');
|
|
$pid = $pidQuery->pluck('pid');
|
|
|
$pid = array_values(array_unique($pid->toArray()));
|
|
$pid = array_values(array_unique($pid->toArray()));
|
|
|
-
|
|
|
|
|
// 构建查询语句
|
|
// 构建查询语句
|
|
|
$query = WebsiteCategory::where($website_id)
|
|
$query = WebsiteCategory::where($website_id)
|
|
|
- ->when(isset($data['is_show']) && $data['is_show'] == 1, function ($query) use ($data) {
|
|
|
|
|
|
|
+ ->when(isset($data['is_show']) && $data['is_show'] == 1 && $data['pid'] == 0, function ($query) use ($data) {
|
|
|
$query->where('is_show', $data['is_show']);
|
|
$query->where('is_show', $data['is_show']);
|
|
|
})
|
|
})
|
|
|
->when(!isset($data['is_show']) || $data['is_show'] != 1, function ($query) use ($data) {
|
|
->when(!isset($data['is_show']) || $data['is_show'] != 1, function ($query) use ($data) {
|
|
@@ -665,9 +664,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$pidResults = $pidQuery->get();
|
|
$pidResults = $pidQuery->get();
|
|
|
if(isset($data['type']) && $data['type'] == 1){
|
|
if(isset($data['type']) && $data['type'] == 1){
|
|
|
$result = $result->map(function ($item) use ($pidResults,$data) {
|
|
$result = $result->map(function ($item) use ($pidResults,$data) {
|
|
|
- if(isset($data['is_show']) && $data['is_show'] == 1){
|
|
|
|
|
- $item->aLIas_pinyin = $item->path;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if(isset($data['is_show']) && $data['is_show'] == 1){
|
|
|
|
|
+ // $item->aLIas_pinyin = $item->path;
|
|
|
|
|
+ // }
|
|
|
$children = $pidResults->where('pid', $item->category_id)->map(function ($child) {
|
|
$children = $pidResults->where('pid', $item->category_id)->map(function ($child) {
|
|
|
if(!empty($child)){
|
|
if(!empty($child)){
|
|
|
return $child;
|
|
return $child;
|
|
@@ -689,7 +688,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
}
|
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
|
} else {
|
|
} else {
|
|
|
- return Result::error("本网站暂无栏目", 0);
|
|
|
|
|
|
|
+ return Result::error("本网站暂无栏目", 0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1552,9 +1551,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
}
|
|
|
$category['children_count'] = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['category_id'])->count();
|
|
$category['children_count'] = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['category_id'])->count();
|
|
|
$parent = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$category['pid'])->select('category_id as parent_id','alias as parent_name','aLIas_pinyin')->first();
|
|
$parent = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$category['pid'])->select('category_id as parent_id','alias as parent_name','aLIas_pinyin')->first();
|
|
|
- $category['parent_id'] = $parent['parent_id']?? '';
|
|
|
|
|
- $category['parent_pinyin'] = $parent['aLIas_pinyin']?? '';
|
|
|
|
|
- $category['parent_name'] = $parent['parent_name']?? '';
|
|
|
|
|
|
|
+ $category['parent_id'] = $parent['parent_id'] ?? '';
|
|
|
|
|
+ $category['parent_pinyin'] = $parent['aLIas_pinyin'] ?? '';
|
|
|
|
|
+ $category['parent_name'] = $parent['parent_name'] ?? '';
|
|
|
return Result::success($category);
|
|
return Result::success($category);
|
|
|
}else{
|
|
}else{
|
|
|
return Result::error("参数错误",0);
|
|
return Result::error("参数错误",0);
|