Browse Source

活动修改后,评价时间不能为null

lizhen_gitee 6 months ago
parent
commit
a1138875a9
1 changed files with 12 additions and 1 deletions
  1. 12 1
      application/admin/model/Trainactive.php

+ 12 - 1
application/admin/model/Trainactive.php

@@ -39,11 +39,22 @@ class Trainactive extends Model
         //文件名
         self::afterUpdate(function ($row) {
 
+            $update = [];
+
             $changed = $row->getChangedData();
             if (isset($changed['files'])) {
+                //文件
                 $files = Db::name('attachment')->where('url','IN',$row['files'])->field('url,filename')->select();
 
-                $update = ['files_json'=>json_encode($files)];
+                $update['files_json'] = json_encode($files);
+            }
+
+            //评价时间不能是null
+            if(empty($row['pingjia_time'])){
+                $update['pingjia_time'] = 0;
+            }
+
+            if(!empty($update)){
                 Db::name('train_active')->where('id',$row['id'])->update($update);
             }
         });