feat: split name into first_name + last_name across users, persons, and companies

Cross-cutting migration affecting the entire stack:
- Database: 3 migrations splitting name columns with data migration
- Models: first_name/last_name on User, Person; contact_first_name/contact_last_name on Company; backward-compatible name accessors
- API: all resources return first_name, last_name, full_name; assignablePersons endpoint updated
- Requests: validation rules updated for all person/user/company forms
- Services: VolunteerRegistrationService, ShiftAssignmentService, InvitationService updated
- Frontend: TypeScript types, Zod schemas, all forms split into Voornaam/Achternaam fields
- Display: all person/user name references use full_name; initials use first_name[0]+last_name[0]
- Tests: all 371 tests passing
- Docs: SCHEMA.md and API.md updated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 23:04:55 +02:00
parent bd4297f891
commit d2f282eb4c
66 changed files with 654 additions and 220 deletions

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('first_name')->after('id');
$table->string('last_name')->after('first_name');
});
DB::table('users')->get()->each(function ($user) {
$parts = explode(' ', $user->name, 2);
DB::table('users')->where('id', $user->id)->update([
'first_name' => $parts[0],
'last_name' => $parts[1] ?? '',
]);
});
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('name');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('name')->after('id');
});
DB::table('users')->get()->each(function ($user) {
DB::table('users')->where('id', $user->id)->update([
'name' => trim("{$user->first_name} {$user->last_name}"),
]);
});
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['first_name', 'last_name']);
});
}
};

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('persons', function (Blueprint $table) {
$table->string('first_name')->after('company_id');
$table->string('last_name')->after('first_name');
});
DB::table('persons')->get()->each(function ($person) {
$parts = explode(' ', $person->name, 2);
DB::table('persons')->where('id', $person->id)->update([
'first_name' => $parts[0],
'last_name' => $parts[1] ?? '',
]);
});
Schema::table('persons', function (Blueprint $table) {
$table->dropColumn('name');
});
}
public function down(): void
{
Schema::table('persons', function (Blueprint $table) {
$table->string('name')->after('company_id');
});
DB::table('persons')->get()->each(function ($person) {
DB::table('persons')->where('id', $person->id)->update([
'name' => trim("{$person->first_name} {$person->last_name}"),
]);
});
Schema::table('persons', function (Blueprint $table) {
$table->dropColumn(['first_name', 'last_name']);
});
}
};

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('companies', function (Blueprint $table) {
$table->string('contact_first_name')->nullable()->after('type');
$table->string('contact_last_name')->nullable()->after('contact_first_name');
});
DB::table('companies')->whereNotNull('contact_name')->get()->each(function ($company) {
$parts = explode(' ', $company->contact_name, 2);
DB::table('companies')->where('id', $company->id)->update([
'contact_first_name' => $parts[0],
'contact_last_name' => $parts[1] ?? '',
]);
});
Schema::table('companies', function (Blueprint $table) {
$table->dropColumn('contact_name');
});
}
public function down(): void
{
Schema::table('companies', function (Blueprint $table) {
$table->string('contact_name')->nullable()->after('type');
});
DB::table('companies')->whereNotNull('contact_first_name')->get()->each(function ($company) {
DB::table('companies')->where('id', $company->id)->update([
'contact_name' => trim("{$company->contact_first_name} {$company->contact_last_name}"),
]);
});
Schema::table('companies', function (Blueprint $table) {
$table->dropColumn(['contact_first_name', 'contact_last_name']);
});
}
};