|
@@ -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(){
|