Explorar o código

修改b端接口:修改网站头部基础信息(将网站标识同步到广告位管理及自助建站模板数据)

15313670163 hai 1 día
pai
achega
3894b8e2d1
Modificáronse 2 ficheiros con 12 adicións e 8 borrados
  1. 11 7
      app/JsonRpc/WebsiteService.php
  2. 1 1
      app/Model/AdPlace.php

+ 11 - 7
app/JsonRpc/WebsiteService.php

@@ -173,17 +173,21 @@ class WebsiteService implements WebsiteServiceInterface
                     Db::rollBack();
                     return Result::error("网站名称简写重复,请填写", 0);
                 }
-                $ad_place = AdPlace::where('website_id', $data['id'])->select('ad_tag','id')->get();
+                $ad_place = AdPlace::where('website_id', $data['id'])->select('ad_tag','id')->get()->toArray();
                 if (!empty($ad_place)) {
                     foreach($ad_place as $key => $val){
                         $ad_keys = explode('_', $val['ad_tag']);
                         $ad_keys[0] = $data['ad_key'];
-                        $ad_tags[$key] = implode('_', $ad_keys);
-                        $up_adtags = AdPlace::where('id', $val['id'])->update(['ad_tag' => $ad_tags[$key]]);
-                        if(empty($up_adtags)){
-                            Db::rollBack();
-                            return Result::error("更新广告位置网站标识失败!", 0);
-                        }
+                        $ad_place[$key]['ad_tag'] = implode('_', $ad_keys);
+
+                        // $up_adtags = AdPlace::where('id', $val['id'])->update(['ad_tag' => $ad_tags[$key]]);
+                        
+                    }
+                    $up_adtags = AdPlace::upsert($ad_place, ['id'], ['ad_tag']);
+
+                    if(empty($up_adtags)){
+                        Db::rollBack();
+                        return Result::error('广告位标识同步失败', 0);
                     }
                 }
                 $template = WebsiteTemplate::where('website_id', $data['id'])->first();

+ 1 - 1
app/Model/AdPlace.php

@@ -18,7 +18,7 @@ class AdPlace extends Model
     /**
      * The attributes that are mass assignable.
      */
-    protected array $fillable = [];
+    protected array $fillable = ['ad_tag'];
 
     /**
      * The attributes that should be cast to native types.