|
|
@@ -1509,28 +1509,26 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
->get()->toArray();
|
|
|
|
|
|
foreach ($website_all as $key => $value) {
|
|
|
- $pidArr = json_decode($value['pid_arr'], true);
|
|
|
+ $category_arr_id = json_decode($value['category_arr_id'], true);
|
|
|
$validPids = [];
|
|
|
$pid = 0;
|
|
|
- foreach ($pidArr as $pidid => $pid) {
|
|
|
+ foreach ($category_arr_id as $pidid => $pid) {
|
|
|
$exists = WebsiteCategory::where('website_id', $website_id)
|
|
|
->where('category_id', $pid)->exists();
|
|
|
if ($exists) {
|
|
|
$validPids[] = $pid;
|
|
|
}
|
|
|
}
|
|
|
- if (count($validPids) != count($pidArr)) {
|
|
|
- if (count($validPids) == 0) {
|
|
|
- $validPids = [0];
|
|
|
+ $pid = $validPids[0];
|
|
|
+ if (count($validPids) != count($category_arr_id)) {
|
|
|
+ if (count($validPids) == 1) {
|
|
|
+ $pid = 0;
|
|
|
}
|
|
|
- var_dump($validPids, '--------222----');
|
|
|
- $pid = end($validPids);
|
|
|
- $category_arr_id = array_push($validPids, $value['category_id']);
|
|
|
- // WebsiteCategory::where('id', $value['id'])->update([
|
|
|
- // 'pid_arr' => json_encode($validPids),
|
|
|
- // 'pid' => $pid,
|
|
|
- // 'category_arr_id' => json_encode($category_arr_id)
|
|
|
- // ]);
|
|
|
+ // $category_arr_id = array_push($validPids, $value['category_id']);
|
|
|
+ WebsiteCategory::where('id', $value['id'])->update([
|
|
|
+ 'real_category_arr_id' => json_encode($validPids),
|
|
|
+ 'real_pid' => $pid,
|
|
|
+ ]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2939,6 +2937,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (isset($data['type']) && !empty($data['type'])) {
|
|
|
array_push($where, ['type', '=', $data['type']]);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
// 根据站点和type获取websiteCategory 中的id
|
|
|
$websiteCategoryids = WebsiteCategory::query()
|
|
|
->where('website_id', '=', $data['website_id'])
|
|
|
@@ -2952,6 +2952,18 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$category_ids = array_unique(array_merge($category_ids, $v));
|
|
|
}
|
|
|
// var_dump($category_ids, '------获取websiteCategory 中的id');
|
|
|
+
|
|
|
+ $realList = WebsiteCategory::query()
|
|
|
+ ->where('website_id', '=', $data['website_id'])
|
|
|
+ ->where('is_url', '!=', 1)
|
|
|
+ ->where('real_pid', '=', $data['pid'])
|
|
|
+ ->select(
|
|
|
+ '*',
|
|
|
+ DB::raw('real_pid AS pid'),
|
|
|
+ DB::raw('real_category_arr_id AS category_arr_id')
|
|
|
+ )
|
|
|
+ ->whereIn('category_id', $category_ids)
|
|
|
+ ->get();
|
|
|
//根据pid取出所有的websiteCategory 中的id
|
|
|
$list = WebsiteCategory::query()
|
|
|
->where('website_id', '=', $data['website_id'])
|
|
|
@@ -2959,6 +2971,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
->where('pid', '=', $data['pid'])
|
|
|
->whereIn('category_id', $category_ids)
|
|
|
->get();
|
|
|
+ $list = $list->merge($realList);
|
|
|
if (empty($list)) {
|
|
|
return Result::error("获取失败", 0);
|
|
|
} else {
|
|
|
@@ -3377,16 +3390,16 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
} else {
|
|
|
// Db::beginTransaction();
|
|
|
// try {
|
|
|
- // $result['website_template'] = WebsiteTemplate::where($where)->update(['status'=>$template_status]);
|
|
|
- // if (empty($result['website_template'])) {
|
|
|
- // return Result::error("修改网站模板状态失败", 0);
|
|
|
- // }
|
|
|
- $result['website_template_info'] = WebsiteTemplateInfo::where($where)->update(['status'=>$data['status']]);
|
|
|
- if (empty($result['website_template_info'])) {
|
|
|
- return Result::error("修改网站基础信息状态失败", 0);
|
|
|
- }
|
|
|
- // Db::commit();
|
|
|
- return Result::success($result);
|
|
|
+ // $result['website_template'] = WebsiteTemplate::where($where)->update(['status'=>$template_status]);
|
|
|
+ // if (empty($result['website_template'])) {
|
|
|
+ // return Result::error("修改网站模板状态失败", 0);
|
|
|
+ // }
|
|
|
+ $result['website_template_info'] = WebsiteTemplateInfo::where($where)->update(['status' => $data['status']]);
|
|
|
+ if (empty($result['website_template_info'])) {
|
|
|
+ return Result::error("修改网站基础信息状态失败", 0);
|
|
|
+ }
|
|
|
+ // Db::commit();
|
|
|
+ return Result::success($result);
|
|
|
// } catch (\Exception $e) {
|
|
|
// Db::rollBack();
|
|
|
// return Result::error($e->getMessage(), 0);
|
|
|
@@ -3573,7 +3586,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$originalCategories = WebsiteCategory::where('website_id', $data['website_id'])->get();
|
|
|
// 克隆网站后的新 ID(假设 $clone_website->id 已存在)
|
|
|
$newWebsiteId = $clone_website->id;
|
|
|
- if($originalCategories && count($originalCategories)>0){
|
|
|
+ if ($originalCategories && count($originalCategories) > 0) {
|
|
|
// 遍历每条记录并克隆
|
|
|
foreach ($originalCategories as $category) {
|
|
|
// 使用 replicate() 方法创建模型副本(不包含主键)
|
|
|
@@ -3587,7 +3600,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
//克隆友情链接 Link 对应的是多个
|
|
|
$originalLinks = Link::where('website_id', $data['website_id'])->get();
|
|
|
- if($originalLinks && count($originalLinks)>0){
|
|
|
+ if ($originalLinks && count($originalLinks) > 0) {
|
|
|
foreach ($originalLinks as $link) {
|
|
|
// 使用 replicate() 方法创建模型副本(不包含主键)
|
|
|
$clonedLink = $link->replicate();
|
|
|
@@ -3599,20 +3612,19 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
//克隆网站底部信息 footer_category 表 和footer_content 表 footer_category.id = footer_content.fcat_id 都是一对多关系
|
|
|
$originalFooterCategories = FooterCategory::where('website_id', $data['website_id'])->get();
|
|
|
- if($originalFooterCategories && count($originalFooterCategories)>0){
|
|
|
+ if ($originalFooterCategories && count($originalFooterCategories) > 0) {
|
|
|
foreach ($originalFooterCategories as $footerCategory) {
|
|
|
$clonedFooterCategory = $footerCategory->replicate();
|
|
|
$clonedFooterCategory->website_id = $newWebsiteId;
|
|
|
$clonedFooterCategory->save();
|
|
|
$originalFooterContents = FooterContent::where('fcat_id', $footerCategory->id)->get();
|
|
|
- if($originalFooterContents && count($originalFooterContents)>0){
|
|
|
+ if ($originalFooterContents && count($originalFooterContents) > 0) {
|
|
|
foreach ($originalFooterContents as $footerContent) {
|
|
|
$clonedFooterContent = $footerContent->replicate();
|
|
|
$clonedFooterContent->fcat_id = $clonedFooterCategory->id;
|
|
|
$clonedFooterContent->save();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
Db::commit();
|