From b5a99ffbcad9144556987b93a4151d95fbcf930c Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Sun, 15 Jan 2023 07:22:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/User.php | 20 +++++++++++++------- resources/views/admin/users/edit.blade.php | 3 ++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 83845d0..23918ef 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; -use Illuminate\Support\Facades\Crypt; use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable @@ -72,15 +71,22 @@ protected static function boot() if ($user->isDirty('id_card')) { - $user->real_name_verified_at = now(); + if ($user->id_card === null) { + $user->real_name_verified_at = null; + } else { + $user->real_name_verified_at = now(); - // 更新生日 - try { - $user->birthday_at = $user->getBirthdayFromIdCard(); - } catch (InvalidFormatException) { - $user->birthday_at = null; + // 更新生日 + try { + $user->birthday_at = $user->getBirthdayFromIdCard(); + } catch (InvalidFormatException) { + $user->birthday_at = null; + } } + + } + }); } diff --git a/resources/views/admin/users/edit.blade.php b/resources/views/admin/users/edit.blade.php index 6e04700..a80b7d1 100644 --- a/resources/views/admin/users/edit.blade.php +++ b/resources/views/admin/users/edit.blade.php @@ -6,7 +6,8 @@

{{ $user->name }}

@if ($user->real_name_verified_at) - 已完成实人验证 + 实人验证于 {{ $user->real_name_verified_at }} +
@endif