From 65835902b85f688ba24ca53ae79da56fc509820c Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Wed, 28 Dec 2022 21:28:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=9F=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Web/AuthController.php | 20 +++++------ app/Models/User.php | 1 + ..._212017_add_birthday_at_to_users_table.php | 35 +++++++++++++++++++ 3 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 database/migrations/2022_12_28_212017_add_birthday_at_to_users_table.php diff --git a/app/Http/Controllers/Web/AuthController.php b/app/Http/Controllers/Web/AuthController.php index 671c73f..2281fe3 100644 --- a/app/Http/Controllers/Web/AuthController.php +++ b/app/Http/Controllers/Web/AuthController.php @@ -112,17 +112,15 @@ public function callback(Request $request) $name = $oauth_user->name; $email = $oauth_user->email; $email_verified_at = $oauth_user->email_verified_at; - $user = User::create([ - 'name' => $name, - 'email' => $email, - 'password' => null, - 'email_verified_at' => $email_verified_at, - 'oauth_id' => $oauth_user->id, - 'provider' => 'LoliArt', - 'provider_id' => $oauth_user->id, - 'real_name' => $oauth_user->real_name, - 'balance' => 0 - ]); + + $user = new User(); + $user->name = $name; + $user->email = $email; + $user->password = null; + $user->email_verified_at = $email_verified_at; + $user->real_name = $oauth_user->real_name; + $user->birthday_at = $oauth_user->birthday; + $user->save(); $request->session()->put('auth.password_confirmed_at', time()); } else { diff --git a/app/Models/User.php b/app/Models/User.php index a6af21f..cb6cd55 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -122,6 +122,7 @@ class User extends Authenticatable 'email_verified_at' => 'datetime', 'balance' => 'decimal:2', 'banned_at' => 'datetime', + 'birthday_at' => 'datetime', ]; protected static function boot() diff --git a/database/migrations/2022_12_28_212017_add_birthday_at_to_users_table.php b/database/migrations/2022_12_28_212017_add_birthday_at_to_users_table.php new file mode 100644 index 0000000..2f83a20 --- /dev/null +++ b/database/migrations/2022_12_28_212017_add_birthday_at_to_users_table.php @@ -0,0 +1,35 @@ +date('birthday_at')->nullable()->after('email_verified_at'); + + // 真实姓名 + $table->string('real_name')->nullable()->after('name'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('birthday_at'); + $table->dropColumn('real_name'); + }); + } +};