|
@@ -225,37 +225,28 @@ class CmsContentTemplateSetRepository {
|
|
|
'apply_type'=>$template->apply_type,
|
|
|
];
|
|
|
$templates = $this->cmsContentTemplate->where($where)->get();
|
|
|
- foreach ($templates->toArray() as $k=>$v){
|
|
|
- if ($v['is_open'] == 1){
|
|
|
- $this->cmsContentTemplate->update(['is_open'=>0]);
|
|
|
+ foreach ($templates->toArray() as $k=>$v) {
|
|
|
+ if ($v['is_open'] == 1) {
|
|
|
+ $update_open = $this->cmsContentTemplate->where('is_open', 1)->update(['is_open' => 0]);
|
|
|
+ if (!$update_open) {
|
|
|
+ throw new HttpException(500, '修改失败,请重试');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- foreach ($tem_array as $k=>$v) {
|
|
|
- if ($v['status'] == 1) {
|
|
|
- $result = $this->cmsContentTemplateSet->where('id', $v['id'])->delete();
|
|
|
- if (!$result) {
|
|
|
- return Response::create([
|
|
|
- 'message' => '删除失败,请重试',
|
|
|
- 'status_code' => 500
|
|
|
- ]);
|
|
|
- }
|
|
|
- }
|
|
|
+ $update_tpl = $this->cmsContentTemplate->where('id', $request['tpl_id'])->update(['is_open' => 1]);
|
|
|
+ if (!$update_tpl) {
|
|
|
+ throw new HttpException(500, '修改失败,请重试');
|
|
|
+ }
|
|
|
+ $res = $this->cmsContentTemplateSet->where('tpl_id',$request['tpl_id'])->update(['status'=>1]);
|
|
|
+ if (!$res){
|
|
|
+ throw new HttpException(500, '修改失败,请重试');
|
|
|
+ }
|
|
|
+ foreach ($templates->toArray() as $k=>$v) {
|
|
|
+ $result = $this->cmsContentTemplateSet->where(['status'=>0,'tpl_id'=>$v['id']])->delete();
|
|
|
+ if ($result) {
|
|
|
+ return Response::create();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- $update_tpl = $this->cmsContentTemplate->where('id',$request['tpl_id'])->update(['is_open'=>1]);
|
|
|
- if (!$update_tpl){
|
|
|
- return Response::create([
|
|
|
- 'message' => '修改失败,请重试',
|
|
|
- 'status_code' => 500
|
|
|
- ]);
|
|
|
- }
|
|
|
- $res = $this->cmsContentTemplateSet->where('tpl_id',$request['tpl_id'])->update(['status'=>1]);
|
|
|
- if (!$res){
|
|
|
- return Response::create([
|
|
|
- 'message' => '修改失败,请重试',
|
|
|
- 'status_code' => 500
|
|
|
- ]);
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|