Add Line ID field to member lifecycle

This commit is contained in:
2026-02-10 15:31:29 +08:00
parent 860dbfb54e
commit f0dbea1af5
18 changed files with 124 additions and 9 deletions

View File

@@ -85,6 +85,7 @@ class ImportMembers extends Command
$memberNumber = isset($indexes['member_number']) ? trim($row[$indexes['member_number']] ?? '') : '';
$nationalId = isset($indexes['national_id']) ? trim($row[$indexes['national_id']] ?? '') : '';
$phone = trim($row[$indexes['phone']] ?? '');
$lineId = isset($indexes['line_id']) ? trim($row[$indexes['line_id']] ?? '') : '';
$phoneHome = isset($indexes['phone_home']) ? trim($row[$indexes['phone_home']] ?? '') : '';
$phoneFax = isset($indexes['phone_fax']) ? trim($row[$indexes['phone_fax']] ?? '') : '';
$birthDate = isset($indexes['birth_date']) ? trim($row[$indexes['birth_date']] ?? '') : '';
@@ -125,6 +126,7 @@ class ImportMembers extends Command
'email' => $email,
'national_id' => $nationalId !== '' ? $nationalId : null,
'phone' => $phone !== '' ? $phone : null,
'line_id' => $lineId !== '' ? $lineId : null,
'phone_home' => $phoneHome !== '' ? $phoneHome : null,
'phone_fax' => $phoneFax !== '' ? $phoneFax : null,
'birth_date' => $birthDate !== '' ? $birthDate : null,

View File

@@ -17,12 +17,13 @@ class AdminMemberController extends Controller
{
$query = Member::query()->with('user');
// Text search (name, email, phone, national ID)
// Text search (name, email, phone, Line ID, national ID)
if ($search = $request->string('search')->toString()) {
$query->where(function ($q) use ($search) {
$q->where('full_name', 'like', "%{$search}%")
->orWhere('email', 'like', "%{$search}%")
->orWhere('phone', 'like', "%{$search}%");
->orWhere('phone', 'like', "%{$search}%")
->orWhere('line_id', 'like', "%{$search}%");
// Search by national ID hash if provided
if (!empty($search)) {
@@ -256,7 +257,13 @@ class AdminMemberController extends Controller
if ($search = $request->string('search')->toString()) {
$query->where(function ($q) use ($search) {
$q->where('full_name', 'like', "%{$search}%")
->orWhere('email', 'like', "%{$search}%");
->orWhere('email', 'like', "%{$search}%")
->orWhere('phone', 'like', "%{$search}%")
->orWhere('line_id', 'like', "%{$search}%");
if (!empty($search)) {
$q->orWhere('national_id_hash', hash('sha256', $search));
}
});
}
@@ -276,6 +283,7 @@ class AdminMemberController extends Controller
'Full Name',
'Email',
'Phone',
'Line ID',
'Address Line 1',
'Address Line 2',
'City',
@@ -297,6 +305,7 @@ class AdminMemberController extends Controller
$member->full_name,
$member->email,
$member->phone,
$member->line_id,
$member->address_line_1,
$member->address_line_2,
$member->city,

View File

@@ -54,6 +54,7 @@ class MemberDashboardController extends Controller
$validated = $request->validate([
'full_name' => ['required', 'string', 'max:255'],
'phone' => ['nullable', 'string', 'max:20'],
'line_id' => ['nullable', 'string', 'max:100'],
'national_id' => ['nullable', 'string', 'max:20'],
'address_line_1' => ['nullable', 'string', 'max:255'],
'address_line_2' => ['nullable', 'string', 'max:255'],
@@ -69,6 +70,7 @@ class MemberDashboardController extends Controller
'full_name' => $validated['full_name'],
'email' => $user->email,
'phone' => $validated['phone'] ?? null,
'line_id' => $validated['line_id'] ?? null,
'national_id' => $validated['national_id'] ?? null,
'address_line_1' => $validated['address_line_1'] ?? null,
'address_line_2' => $validated['address_line_2'] ?? null,

View File

@@ -32,6 +32,7 @@ class PublicMemberRegistrationController extends Controller
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email', 'unique:members,email'],
'password' => ['required', 'confirmed', Password::defaults()],
'phone' => ['nullable', 'string', 'max:20'],
'line_id' => ['nullable', 'string', 'max:100'],
'national_id' => ['nullable', 'string', 'max:20'],
'address_line_1' => ['nullable', 'string', 'max:255'],
'address_line_2' => ['nullable', 'string', 'max:255'],
@@ -57,6 +58,7 @@ class PublicMemberRegistrationController extends Controller
'full_name' => $validated['full_name'],
'email' => $validated['email'],
'phone' => $validated['phone'] ?? null,
'line_id' => $validated['line_id'] ?? null,
'national_id' => $validated['national_id'] ?? null,
'address_line_1' => $validated['address_line_1'] ?? null,
'address_line_2' => $validated['address_line_2'] ?? null,

View File

@@ -27,6 +27,7 @@ class StoreMemberRequest extends FormRequest
'email' => ['required', 'email', 'max:255', 'unique:users,email'],
'national_id' => ['nullable', 'string', 'max:50'],
'phone' => ['nullable', 'string', 'max:50'],
'line_id' => ['nullable', 'string', 'max:100'],
'phone_home' => ['nullable', 'string', 'max:50'],
'phone_fax' => ['nullable', 'string', 'max:50'],
'birth_date' => ['nullable', 'date'],

View File

@@ -33,6 +33,7 @@ class UpdateMemberRequest extends FormRequest
'email' => ['required', 'email', 'max:255'],
'national_id' => ['nullable', 'string', 'max:50'],
'phone' => ['nullable', 'string', 'max:50'],
'line_id' => ['nullable', 'string', 'max:100'],
'phone_home' => ['nullable', 'string', 'max:50'],
'phone_fax' => ['nullable', 'string', 'max:50'],
'birth_date' => ['nullable', 'date'],

View File

@@ -42,6 +42,7 @@ class Member extends Model
'full_name',
'email',
'phone',
'line_id',
'phone_home',
'phone_fax',
'address_line_1',

View File

@@ -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('members', function (Blueprint $table) {
$table->string('line_id', 100)->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('members', function (Blueprint $table) {
$table->dropColumn('line_id');
});
}
};

View File

@@ -169,7 +169,7 @@
</p>
</div>
<div class="grid gap-6 sm:grid-cols-2">
<div class="grid gap-6 sm:grid-cols-3">
<div>
<label for="phone" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
行動電話
@@ -186,6 +186,22 @@
@enderror
</div>
<div>
<label for="line_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
Line ID
</label>
<input
type="text"
name="line_id"
id="line_id"
value="{{ old('line_id') }}"
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
>
@error('line_id')
<p class="mt-2 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
</div>
<div>
<label for="phone_home" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
室內電話

View File

@@ -167,7 +167,7 @@
</p>
</div>
<div class="grid gap-6 sm:grid-cols-2">
<div class="grid gap-6 sm:grid-cols-3">
<div>
<label for="phone" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
行動電話
@@ -184,6 +184,22 @@
@enderror
</div>
<div>
<label for="line_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
Line ID
</label>
<input
type="text"
name="line_id"
id="line_id"
value="{{ old('line_id', $member->line_id) }}"
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
>
@error('line_id')
<p class="mt-2 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
</div>
<div>
<label for="phone_home" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
室內電話

View File

@@ -17,6 +17,7 @@
<li><code class="text-gray-800 dark:text-gray-200">member_number</code> (optional)</li>
<li><code class="text-gray-800 dark:text-gray-200">email</code></li>
<li><code class="text-gray-800 dark:text-gray-200">phone</code></li>
<li><code class="text-gray-800 dark:text-gray-200">line_id</code> (optional)</li>
<li><code class="text-gray-800 dark:text-gray-200">phone_home</code> (optional)</li>
<li><code class="text-gray-800 dark:text-gray-200">phone_fax</code> (optional)</li>
<li><code class="text-gray-800 dark:text-gray-200">birth_date</code> (YYYY-MM-DD, optional)</li>

View File

@@ -12,7 +12,7 @@
<form method="GET" action="{{ route('admin.members.index') }}" class="mb-4 space-y-4" role="search" aria-label="搜尋和篩選會員">
<div>
<label for="search" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
依姓名、電子郵件、電話或身分證號搜尋
依姓名、電子郵件、電話、Line ID 或身分證號搜尋
</label>
<input
type="text"
@@ -23,7 +23,7 @@
placeholder="輸入搜尋關鍵字..."
>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
在姓名、電子郵件、電話號碼和身分證號中搜尋
在姓名、電子郵件、電話號碼、Line ID 和身分證號中搜尋
</p>
</div>

View File

@@ -103,6 +103,15 @@
</dd>
</div>
<div class="overflow-hidden rounded-lg bg-gray-50 dark:bg-gray-700 px-4 py-5 sm:p-6">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">
Line ID
</dt>
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">
{{ $member->line_id ?? __('Not set') }}
</dd>
</div>
<div class="overflow-hidden rounded-lg bg-gray-50 dark:bg-gray-700 px-4 py-5 sm:p-6">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">
室內電話/傳真

View File

@@ -34,6 +34,13 @@
<x-input-error :messages="$errors->get('phone')" class="mt-2" />
</div>
<!-- Line ID -->
<div class="mt-4">
<x-input-label for="line_id" :value="__('Line ID')" />
<x-text-input id="line_id" class="block mt-1 w-full" type="text" name="line_id" :value="old('line_id')" maxlength="100" />
<x-input-error :messages="$errors->get('line_id')" class="mt-2" />
</div>
<!-- National ID (Optional) -->
<div class="mt-4">
<x-input-label for="national_id" :value="__('National ID (Optional)')" />

View File

@@ -92,6 +92,15 @@
</dd>
</div>
<div class="overflow-hidden rounded-lg bg-gray-50 dark:bg-gray-700 px-4 py-5 sm:p-6">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">
{{ __('Line ID') }}
</dt>
<dd class="mt-1 text-xl font-semibold text-gray-900 dark:text-gray-100">
{{ $member->line_id ?: __('Not set') }}
</dd>
</div>
<div class="overflow-hidden rounded-lg bg-gray-50 dark:bg-gray-700 px-4 py-5 sm:p-6">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">
{{ __('Membership Type') }}

View File

@@ -50,6 +50,13 @@
<x-input-error :messages="$errors->get('phone')" class="mt-2" />
</div>
<!-- Line ID -->
<div class="mt-4">
<x-input-label for="line_id" :value="__('Line ID')" />
<x-text-input id="line_id" class="block mt-1 w-full" type="text" name="line_id" :value="old('line_id')" maxlength="100" />
<x-input-error :messages="$errors->get('line_id')" class="mt-2" />
</div>
<!-- National ID (Optional) -->
<div class="mt-4">
<x-input-label for="national_id" :value="__('National ID (Optional)')" />

View File

@@ -41,6 +41,7 @@ class MemberRegistrationTest extends TestCase
'password' => 'Password123!',
'password_confirmation' => 'Password123!',
'phone' => '0912345678',
'line_id' => 'john_doe_line',
'address_line_1' => '123 Test St',
'city' => 'Taipei',
'postal_code' => '100',
@@ -62,6 +63,7 @@ class MemberRegistrationTest extends TestCase
'full_name' => 'John Doe',
'email' => 'john@example.com',
'phone' => '0912345678',
'line_id' => 'john_doe_line',
'membership_status' => Member::STATUS_PENDING,
]);
}
@@ -256,6 +258,7 @@ class MemberRegistrationTest extends TestCase
$member = Member::where('email', 'john@example.com')->first();
$this->assertNull($member->phone);
$this->assertNull($member->line_id);
$this->assertNull($member->address_line_1);
}
}

View File

@@ -132,6 +132,7 @@ trait CreatesMemberData
'password' => 'Password123!',
'password_confirmation' => 'Password123!',
'phone' => '0912345678',
'line_id' => 'line.member.test',
'national_id' => 'A123456789',
'address_line_1' => '123 Test Street',
'address_line_2' => '',