浏览代码

修复以往数据

Zhouzhendong 5 年之前
父节点
当前提交
3c8f798f92
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10 3
      app/Http/Controllers/TestController.php

+ 10 - 3
app/Http/Controllers/TestController.php

@@ -158,9 +158,16 @@ class TestController extends Controller
         dd(Region::query()->where("id",">=",404)->where("id","<=",432)->delete());
     }
     public function tt1(){
-        $a = new Owner();
-        $a->load("ownerPriceOperations");
-        dd($a);
+       $owner = Owner::query()->withCount(["ownerStoragePriceModels","ownerPriceOperations","ownerPriceExpresses","ownerPriceLogistics","ownerPriceDirectLogistics"])->get();
+       foreach ($owner as $o){
+           $arr = [];
+           if ($o->owner_storage_price_models_count)$arr[] = 0;
+           if ($o->owner_price_operations_count)$arr[] = 1;
+           if ($o->owner_price_expresses_count)$arr[] = 2;
+           if ($o->owner_price_logistics_count)$arr[] = 3;
+           if ($o->owner_price_direct_logistics_count)$arr[] = 4;
+           $o->update(["relevance"=>json_encode($arr)]);
+       }
     }
     public function zzd(){
         ini_set('max_execution_time',2500);