From 7ebd71ba565bf39338b0772a7a6aa66228255f5b Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Thu, 2 Nov 2023 13:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8Cid=20?= =?UTF-8?q?=E9=9A=8F=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/User.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/model/User.php b/app/model/User.php index 5a96dcd..5e1d877 100644 --- a/app/model/User.php +++ b/app/model/User.php @@ -37,7 +37,8 @@ class User extends Model // 密码加盐值后哈希存储 $password = $this->generateHashedPassword($data['password'], $salt); - $User->save([ + $lastId = User::withTrashed()->where('id','>=',1)->order('id desc')->value('id'); + $save = [ // 随机头像 'avatar' => rand_avatar(), 'password' => $password, @@ -46,7 +47,12 @@ class User extends Model 'aid' => $data['aid'], 'identity' => $identity, 'register_time' => date("Y-m-d H:i:s",time()) - ]); + ]; + if ($lastId) { + $rand = rand(2,50); + $save['id'] = $lastId + $rand; + } + $User->save($save); return $User->id; }