新增曾用名
This commit is contained in:
@@ -85,6 +85,7 @@ class UserController extends Controller
|
||||
$activePosition = $targetUser->activePosition?->load('position.department')->position;
|
||||
$data = [
|
||||
'username' => $targetUser->username,
|
||||
'previous_name' => $targetUser->previous_name,
|
||||
'sex' => match ((int) $targetUser->sex) {
|
||||
1 => '男', 2 => '女', default => ''
|
||||
},
|
||||
|
||||
@@ -31,6 +31,7 @@ class UpdateProfileRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'previous_name' => ['nullable', 'string', 'max:50'],
|
||||
'sex' => ['required', 'in:0,1,2'],
|
||||
'headface' => ['required', 'string', 'max:50'], // 比如存放 01.gif - 50.gif
|
||||
'sign' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
@@ -45,6 +45,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
protected $fillable = [
|
||||
'username',
|
||||
'previous_name',
|
||||
'password',
|
||||
'email',
|
||||
'sex',
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('previous_name', 50)->nullable()->after('username')->comment('曾用名');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('previous_name');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -345,6 +345,7 @@ export async function savePassword() {
|
||||
*/
|
||||
export async function saveSettings() {
|
||||
const profileData = {
|
||||
previous_name: element("set-previous-name").value || "",
|
||||
sex: element("set-sex").value,
|
||||
email: element("set-email").value,
|
||||
email_code: element("set-email-code")?.value || "",
|
||||
|
||||
@@ -128,6 +128,12 @@
|
||||
<div style="margin-bottom:16px; border:1px solid #e0e0e0; border-radius:6px; padding:12px;">
|
||||
<div style="font-size:12px; font-weight:bold; color:#336699; margin-bottom:8px;">👤 个人资料</div>
|
||||
<div style="display:flex; flex-direction:column; gap:6px;">
|
||||
<div style="display:flex; align-items:center; gap:8px;">
|
||||
<label style="font-size:12px; width:50px; text-align:right;">曾用名:</label>
|
||||
<input id="set-previous-name" type="text" value="{{ Auth::user()->previous_name ?? '' }}"
|
||||
placeholder="设置曾用名(选填)"
|
||||
style="flex:1; padding:5px; border:1px solid #ccc; border-radius:4px; font-size:12px;">
|
||||
</div>
|
||||
<div style="display:flex; align-items:center; gap:8px;">
|
||||
<label style="font-size:12px; width:50px; text-align:right;">性别:</label>
|
||||
<select id="set-sex"
|
||||
|
||||
@@ -45,6 +45,11 @@
|
||||
<div class="profile-info">
|
||||
<h4>
|
||||
<span x-text="userInfo.username"></span>
|
||||
<template x-if="userInfo.previous_name">
|
||||
<span style="font-size:11px; color:#999; font-weight:normal; margin-left:6px;">
|
||||
(曾用名: <span x-text="userInfo.previous_name"></span>)
|
||||
</span>
|
||||
</template>
|
||||
<span class="level-badge" x-text="'LV.' + userInfo.user_level"></span>
|
||||
<span class="sex-badge"
|
||||
x-text="userInfo.sex === '男' ? '♂' : (userInfo.sex === '女' ? '♀' : '')"
|
||||
|
||||
Reference in New Issue
Block a user