Quellcode durchsuchen

修改模板名称微调

duqinya vor 5 Jahren
Ursprung
Commit
fa81224550
2 geänderte Dateien mit 15 neuen und 2 gelöschten Zeilen
  1. 14 1
      app/Repositories/CmsContentTemplateRepository.php
  2. 1 1
      routes/api.php

+ 14 - 1
app/Repositories/CmsContentTemplateRepository.php

@@ -114,7 +114,20 @@ class CmsContentTemplateRepository {
      * @param $data
      * @return mixed
      */
-    public function updateTemplateName($data){
+    public function updateTemplateName($data)
+    {
+        $template = $this->cmsContentTemplate->select('city_id','apply_type')->where('id',$data['id'])->first();
+        $template_array = $this->cmsContentTemplate->where(['city_id'=>$template->city_id,'apply_type'=>$template->apply_type])->get();
+
+        if (count($template_array)>1){
+            foreach ($template_array->toArray() as $value){
+                $res = $this->cmsContentTemplate->where('id',$value['id'])->update(['title'=>$data['title']]);
+                if (!$res){
+                    throw new HttpException(500, '修改失败,请重试');
+                }
+            }
+        }
+
         return $this->cmsContentTemplate->where('id',$data['id'])->update(['title'=>$data['title']]);
     }
 }

+ 1 - 1
routes/api.php

@@ -66,7 +66,7 @@ $api->version('v1', [
         $api->post('/template/create', 'CmsContentTemplateController@create');
         //列表修改模板状态
         $api->put('/template/edit', 'CmsContentTemplateController@edit');
-        //列表修改模板名称状态
+        //列表修改模板名称
         $api->put('/template/editName', 'CmsContentTemplateController@editTemplateName');
 
         //banner设置