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:
@@ -64,7 +64,9 @@ final class InvitationController extends Controller
|
||||
return $this->success([
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'first_name' => $user->first_name,
|
||||
'last_name' => $user->last_name,
|
||||
'full_name' => $user->full_name,
|
||||
'email' => $user->email,
|
||||
],
|
||||
'token' => $sanctumToken,
|
||||
|
||||
@@ -145,7 +145,8 @@ final class ShiftAssignmentController extends Controller
|
||||
$persons = Person::where('event_id', $festivalEventId)
|
||||
->where('status', PersonStatus::APPROVED)
|
||||
->with('crowdType')
|
||||
->orderBy('name')
|
||||
->orderBy('first_name')
|
||||
->orderBy('last_name')
|
||||
->get();
|
||||
|
||||
// Batch: tags for all persons with user_id
|
||||
@@ -184,7 +185,9 @@ final class ShiftAssignmentController extends Controller
|
||||
|
||||
return [
|
||||
'id' => $person->id,
|
||||
'name' => $person->name,
|
||||
'first_name' => $person->first_name,
|
||||
'last_name' => $person->last_name,
|
||||
'full_name' => $person->full_name,
|
||||
'email' => $person->email,
|
||||
'status' => $person->status,
|
||||
'crowd_type' => $person->crowdType ? [
|
||||
@@ -222,7 +225,7 @@ final class ShiftAssignmentController extends Controller
|
||||
->sortBy([
|
||||
['already_assigned', 'asc'],
|
||||
['is_available', 'desc'],
|
||||
['name', 'asc'],
|
||||
['first_name', 'asc'],
|
||||
])
|
||||
->values();
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ final class AcceptInvitationRequest extends FormRequest
|
||||
$userExists = $invitation && User::where('email', $invitation->email)->exists();
|
||||
|
||||
return [
|
||||
'name' => [$userExists ? 'nullable' : 'required', 'string', 'max:255'],
|
||||
'first_name' => [$userExists ? 'nullable' : 'required', 'string', 'max:255'],
|
||||
'last_name' => [$userExists ? 'nullable' : 'required', 'string', 'max:255'],
|
||||
'password' => [$userExists ? 'nullable' : 'required', 'string', 'min:8', 'confirmed'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ final class StoreCompanyRequest extends FormRequest
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:100'],
|
||||
'type' => ['required', 'in:supplier,partner,agency,venue,other'],
|
||||
'contact_name' => ['nullable', 'string', 'max:100'],
|
||||
'contact_first_name' => ['nullable', 'string', 'max:100'],
|
||||
'contact_last_name' => ['nullable', 'string', 'max:100'],
|
||||
'contact_email' => ['nullable', 'email', 'max:100'],
|
||||
'contact_phone' => ['nullable', 'string', 'max:30'],
|
||||
];
|
||||
|
||||
@@ -18,7 +18,8 @@ final class StorePersonRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'crowd_type_id' => ['required', 'ulid', 'exists:crowd_types,id'],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:30'],
|
||||
'company_id' => ['nullable', 'ulid', 'exists:companies,id'],
|
||||
|
||||
@@ -19,7 +19,8 @@ final class UpdateCompanyRequest extends FormRequest
|
||||
return [
|
||||
'name' => ['sometimes', 'string', 'max:100'],
|
||||
'type' => ['sometimes', 'in:supplier,partner,agency,venue,other'],
|
||||
'contact_name' => ['nullable', 'string', 'max:100'],
|
||||
'contact_first_name' => ['nullable', 'string', 'max:100'],
|
||||
'contact_last_name' => ['nullable', 'string', 'max:100'],
|
||||
'contact_email' => ['nullable', 'email', 'max:100'],
|
||||
'contact_phone' => ['nullable', 'string', 'max:30'],
|
||||
];
|
||||
|
||||
@@ -18,7 +18,8 @@ final class UpdatePersonRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'crowd_type_id' => ['sometimes', 'ulid', 'exists:crowd_types,id'],
|
||||
'name' => ['sometimes', 'string', 'max:255'],
|
||||
'first_name' => ['sometimes', 'string', 'max:255'],
|
||||
'last_name' => ['sometimes', 'string', 'max:255'],
|
||||
'email' => ['sometimes', 'email', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:30'],
|
||||
'company_id' => ['nullable', 'ulid', 'exists:companies,id'],
|
||||
|
||||
@@ -19,7 +19,8 @@ final class VolunteerRegistrationRequest extends FormRequest
|
||||
|
||||
if ($user) {
|
||||
$this->merge([
|
||||
'name' => $user->name,
|
||||
'first_name' => $user->first_name,
|
||||
'last_name' => $user->last_name,
|
||||
'email' => $user->email,
|
||||
'_authenticated' => true,
|
||||
]);
|
||||
@@ -30,7 +31,8 @@ final class VolunteerRegistrationRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required_without:_authenticated', 'string', 'max:255'],
|
||||
'first_name' => ['required_without:_authenticated', 'string', 'max:255'],
|
||||
'last_name' => ['required_without:_authenticated', 'string', 'max:255'],
|
||||
'email' => ['required_without:_authenticated', 'email', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:50'],
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@ final class CompanyResource extends JsonResource
|
||||
'organisation_id' => $this->organisation_id,
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'contact_name' => $this->contact_name,
|
||||
'contact_first_name' => $this->contact_first_name,
|
||||
'contact_last_name' => $this->contact_last_name,
|
||||
'contact_full_name' => $this->contact_full_name,
|
||||
'contact_email' => $this->contact_email,
|
||||
'contact_phone' => $this->contact_phone,
|
||||
'persons_count' => $this->whenCounted('persons'),
|
||||
|
||||
@@ -13,7 +13,9 @@ final class MeResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'full_name' => $this->full_name,
|
||||
'email' => $this->email,
|
||||
'timezone' => $this->timezone,
|
||||
'locale' => $this->locale,
|
||||
|
||||
@@ -13,7 +13,9 @@ final class MemberResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'full_name' => $this->full_name,
|
||||
'email' => $this->email,
|
||||
'role' => $this->pivot?->role,
|
||||
'avatar' => $this->avatar,
|
||||
|
||||
@@ -14,7 +14,9 @@ final class PersonResource extends JsonResource
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'event_id' => $this->event_id,
|
||||
'name' => $this->name,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'full_name' => $this->full_name,
|
||||
'email' => $this->email,
|
||||
'phone' => $this->phone,
|
||||
'status' => $this->status,
|
||||
@@ -33,7 +35,9 @@ final class PersonResource extends JsonResource
|
||||
'match_id' => $match->id,
|
||||
'matched_user' => [
|
||||
'id' => $match->matchedUser->id,
|
||||
'name' => $match->matchedUser->name,
|
||||
'first_name' => $match->matchedUser->first_name,
|
||||
'last_name' => $match->matchedUser->last_name,
|
||||
'full_name' => $match->matchedUser->full_name,
|
||||
'email' => $match->matchedUser->email,
|
||||
],
|
||||
'matched_on' => $match->matched_on->value,
|
||||
|
||||
@@ -13,7 +13,9 @@ final class UserResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'full_name' => $this->full_name,
|
||||
'email' => $this->email,
|
||||
'roles' => $this->getRoleNames()->values()->all(),
|
||||
'timezone' => $this->timezone,
|
||||
|
||||
@@ -22,11 +22,21 @@ final class Company extends Model
|
||||
'organisation_id',
|
||||
'name',
|
||||
'type',
|
||||
'contact_name',
|
||||
'contact_first_name',
|
||||
'contact_last_name',
|
||||
'contact_email',
|
||||
'contact_phone',
|
||||
];
|
||||
|
||||
public function getContactFullNameAttribute(): ?string
|
||||
{
|
||||
if (! $this->contact_first_name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim("{$this->contact_first_name} {$this->contact_last_name}");
|
||||
}
|
||||
|
||||
public function organisation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organisation::class);
|
||||
|
||||
@@ -28,7 +28,8 @@ final class Person extends Model
|
||||
'event_id',
|
||||
'crowd_type_id',
|
||||
'company_id',
|
||||
'name',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'phone',
|
||||
'status',
|
||||
@@ -37,6 +38,16 @@ final class Person extends Model
|
||||
'custom_fields',
|
||||
];
|
||||
|
||||
public function getFullNameAttribute(): string
|
||||
{
|
||||
return trim("{$this->first_name} {$this->last_name}");
|
||||
}
|
||||
|
||||
public function getNameAttribute(): string
|
||||
{
|
||||
return $this->full_name;
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -24,7 +24,8 @@ final class User extends Authenticatable
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'password',
|
||||
'timezone',
|
||||
@@ -32,6 +33,16 @@ final class User extends Authenticatable
|
||||
'avatar',
|
||||
];
|
||||
|
||||
public function getFullNameAttribute(): string
|
||||
{
|
||||
return trim("{$this->first_name} {$this->last_name}");
|
||||
}
|
||||
|
||||
public function getNameAttribute(): string
|
||||
{
|
||||
return $this->full_name;
|
||||
}
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
|
||||
@@ -76,7 +76,8 @@ final class InvitationService
|
||||
}
|
||||
|
||||
$user = User::create([
|
||||
'name' => Str::before($invitation->email, '@'),
|
||||
'first_name' => Str::before($invitation->email, '@'),
|
||||
'last_name' => '',
|
||||
'email' => $invitation->email,
|
||||
'password' => $password,
|
||||
'email_verified_at' => now(),
|
||||
|
||||
@@ -102,7 +102,7 @@ final class ShiftAssignmentService
|
||||
->performedOn($existing)
|
||||
->withProperties([
|
||||
'previous_status' => $previousStatus,
|
||||
'person_name' => $person->name,
|
||||
'person_name' => $person->full_name,
|
||||
])
|
||||
->log('shift_assignment.reactivated');
|
||||
|
||||
@@ -124,7 +124,7 @@ final class ShiftAssignmentService
|
||||
'filled_slots' => $filledSlots,
|
||||
'slots_total' => $shift->slots_total,
|
||||
'person_id' => $person->id,
|
||||
'person_name' => $person->name,
|
||||
'person_name' => $person->full_name,
|
||||
])
|
||||
->log('shift.overbooked_assignment');
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ final class VolunteerRegistrationService
|
||||
[
|
||||
'user_id' => $user?->id,
|
||||
'crowd_type_id' => $volunteerCrowdType->id,
|
||||
'name' => $user?->name ?? $validated['name'],
|
||||
'first_name' => $user?->first_name ?? $validated['first_name'],
|
||||
'last_name' => $user?->last_name ?? $validated['last_name'],
|
||||
'phone' => $validated['phone'] ?? null,
|
||||
'status' => PersonStatus::PENDING,
|
||||
'custom_fields' => [
|
||||
@@ -119,7 +120,7 @@ final class VolunteerRegistrationService
|
||||
return;
|
||||
}
|
||||
|
||||
if ($existing->status !== PersonStatus::REJECTED) {
|
||||
if ($existing->status !== PersonStatus::REJECTED->value) {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => ['Already registered for this event.'],
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user