|
@@ -640,14 +640,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
->when(isset($data['is_show']) && $data['is_show'] == 1 && $data['pid'] == 0, 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']), function ($query) use ($data) {
|
|
|
$query->where('pid', $data['pid']);
|
|
$query->where('pid', $data['pid']);
|
|
|
})
|
|
})
|
|
|
->offset($data['placeid'])
|
|
->offset($data['placeid'])
|
|
|
->limit($data['num'])
|
|
->limit($data['num'])
|
|
|
->orderBy('sort');
|
|
->orderBy('sort');
|
|
|
// 如果 $pid 数组不为空,添加 CASE WHEN 条件
|
|
// 如果 $pid 数组不为空,添加 CASE WHEN 条件
|
|
|
-
|
|
|
|
|
|
|
+ // return Result::success(!isset($data['is_show']) );
|
|
|
if (!empty($pid)) {
|
|
if (!empty($pid)) {
|
|
|
$placeholders = implode(',', array_fill(0, count($pid), '?'));
|
|
$placeholders = implode(',', array_fill(0, count($pid), '?'));
|
|
|
$query->selectRaw("website_category.*, CASE WHEN website_category.category_id IN ($placeholders) THEN 1 ELSE 0 END AS children_count", $pid);
|
|
$query->selectRaw("website_category.*, CASE WHEN website_category.category_id IN ($placeholders) THEN 1 ELSE 0 END AS children_count", $pid);
|
|
@@ -1551,6 +1551,7 @@ 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();
|
|
|
|
|
+ // return Result::success($parent);
|
|
|
$category['parent_id'] = $parent['parent_id'] ?? '';
|
|
$category['parent_id'] = $parent['parent_id'] ?? '';
|
|
|
$category['parent_pinyin'] = $parent['aLIas_pinyin'] ?? '';
|
|
$category['parent_pinyin'] = $parent['aLIas_pinyin'] ?? '';
|
|
|
$category['parent_name'] = $parent['parent_name'] ?? '';
|
|
$category['parent_name'] = $parent['parent_name'] ?? '';
|
|
@@ -2195,12 +2196,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
}
|
|
|
if (isset($data['pinyin']) &&!empty($data['pinyin'])) {
|
|
if (isset($data['pinyin']) &&!empty($data['pinyin'])) {
|
|
|
$result = WebsiteCategory::where('website_category.website_id', $data['website_id'])
|
|
$result = WebsiteCategory::where('website_category.website_id', $data['website_id'])
|
|
|
- ->where('website_category.aLIas_pinyin', $data['pinyin'])
|
|
|
|
|
- ->leftJoin('website_category as pc', function ($join) use ($data) {
|
|
|
|
|
- $join->on('pc.pid', '=', 'website_category.category_id')
|
|
|
|
|
- ->where('pc.website_id', '=', $data['website_id']);
|
|
|
|
|
- })
|
|
|
|
|
- ->select('website_category.category_id','website_category.type', 'website_category.alias', DB::raw('CASE WHEN pc.category_id IS NOT NULL THEN 1 ELSE 0 END as children_count'))
|
|
|
|
|
|
|
+ ->where('website_category.path', $data['pinyin'])
|
|
|
|
|
+ // ->leftJoin('website_category as pc', function ($join) use ($data) {
|
|
|
|
|
+ // $join->on('pc.pid', '=', 'website_category.category_id')
|
|
|
|
|
+ // ->where('pc.website_id', '=', $data['website_id']);
|
|
|
|
|
+ // })
|
|
|
|
|
+ ->select('website_category.category_id','website_category.type', 'website_category.alias',)
|
|
|
->first();
|
|
->first();
|
|
|
}
|
|
}
|
|
|
if(isset($data['foot_pinyin']) &&!empty($data['foot_pinyin'])){
|
|
if(isset($data['foot_pinyin']) &&!empty($data['foot_pinyin'])){
|