|
@@ -20,37 +20,38 @@ class CmsContentTemplateSetRepository {
|
|
|
//banner模板选专题-被使用计数
|
|
|
public function countSubject($request)
|
|
|
{
|
|
|
- if ($request['type'] == 0){
|
|
|
- $rule = json_decode($request['rule'],true);
|
|
|
- if ($rule['link_type'] == 1){
|
|
|
- $templates = $this->cmsSubject->where('id',intval($rule['link_url']))->first();
|
|
|
- $templates->used_count +=1;
|
|
|
+ if ($request['type'] == 0) {
|
|
|
+ $rule = json_decode($request['rule'], true);
|
|
|
+ if ($rule['link_type'] == 1) {
|
|
|
+ $templates = $this->cmsSubject->where('id', intval($rule['link_url']))->first();
|
|
|
+ $templates->used_count += 1;
|
|
|
$templates->save();
|
|
|
}
|
|
|
- }else{
|
|
|
- $subject_id_array = json_decode($request['old_rule'],true);
|
|
|
- $rule = json_decode($request['rule'],true);
|
|
|
- if ($subject_id_array['link_type'] == 1 && $rule['link_type'] == 1){//链接方式都为专题
|
|
|
- if ($subject_id_array['link_url'] != $rule['link_type']){
|
|
|
- $templates = $this->cmsSubject->where('id',intval($subject_id_array['link_url']))->first();
|
|
|
+ }
|
|
|
+ if ($request['type'] == 1) {
|
|
|
+ $subject_id_array = json_decode($request['old_rule'], true);
|
|
|
+ $rule = json_decode($request['rule'], true);
|
|
|
+ if ($subject_id_array['link_type'] == 1 && $rule['link_type'] == 1) {//链接方式都为专题
|
|
|
+ if ($subject_id_array['link_url'] != $rule['link_type']) {
|
|
|
+ $templates = $this->cmsSubject->where('id', intval($subject_id_array['link_url']))->first();
|
|
|
$update_template = [
|
|
|
- $templates->used_count -=1
|
|
|
+ $templates->used_count -= 1
|
|
|
];
|
|
|
$templates->update($update_template);
|
|
|
|
|
|
- $templates = $this->cmsSubject->where('id',intval($rule['link_type']))->first();
|
|
|
- $templates->used_count +=1;
|
|
|
+ $templates = $this->cmsSubject->where('id', intval($rule['link_type']))->first();
|
|
|
+ $templates->used_count += 1;
|
|
|
$templates->save();
|
|
|
}
|
|
|
- }elseif ($subject_id_array['link_type'] == 1 && $rule['link_type'] != 1){
|
|
|
- $templates = $this->cmsSubject->where('id',intval($subject_id_array['link_url']))->first();
|
|
|
+ } elseif ($subject_id_array['link_type'] == 1 && $rule['link_type'] != 1) {
|
|
|
+ $templates = $this->cmsSubject->where('id', intval($subject_id_array['link_url']))->first();
|
|
|
$update_template = [
|
|
|
- $templates->used_count -=1
|
|
|
+ $templates->used_count -= 1
|
|
|
];
|
|
|
$templates->update($update_template);
|
|
|
- }elseif ($subject_id_array['link_type'] != 1 && $rule['link_type'] == 1){
|
|
|
- $templates = $this->cmsSubject->where('id',intval($request['rule']['link_url']))->first();
|
|
|
- $templates->used_count +=1;
|
|
|
+ } elseif ($subject_id_array['link_type'] != 1 && $rule['link_type'] == 1) {
|
|
|
+ $templates = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
|
|
|
+ $templates->used_count += 1;
|
|
|
$templates->save();
|
|
|
}
|
|
|
}
|