xg il y a 2 ans
Parent
commit
a61ccca52d
1 fichiers modifiés avec 16 ajouts et 0 suppressions
  1. 16 0
      application/admin/model/Admin.php

+ 16 - 0
application/admin/model/Admin.php

@@ -101,6 +101,22 @@ class Admin extends Model
                 $admin['com_mobile']=null;
             }
         });
+        self::beforeInsert(function (self $admin){
+            if(!empty($admin['com_mobile'])){
+                $has=self::where('com_mobile',$admin['com_mobile'])->find();
+                if($has){
+                    throw_user('联系人电话不能重复');
+                }
+            }
+        });
+        self::beforeUpdate(function (self $admin){
+            if(!empty($admin['com_mobile'])){
+                $has=self::where('com_mobile',$admin['com_mobile'])->where('id','<>',$admin['id'])->find();
+                if($has){
+                    throw_user('联系人电话不能重复');
+                }
+            }
+        });
     }
 
     public static function getAdmins(){