Implements the full identity matching engine: email matching (HIGH confidence), fuzzy name matching with Levenshtein distance (MEDIUM confidence, upgradable to HIGH with DOB tiebreaker), manual link/unlink, revert confirmed matches, and automatic detection via PersonObserver. Includes 33 comprehensive tests, frontend integration with confirm/dismiss/unlink UI, and match indicators in the persons list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
51 lines
1.9 KiB
PHP
51 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\Api\V1;
|
|
|
|
use App\Models\Person;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
final class MeResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'first_name' => $this->first_name,
|
|
'last_name' => $this->last_name,
|
|
'full_name' => $this->full_name,
|
|
'date_of_birth' => $this->date_of_birth?->toDateString(),
|
|
'email' => $this->email,
|
|
'timezone' => $this->timezone,
|
|
'locale' => $this->locale,
|
|
'avatar' => $this->avatar,
|
|
'email_verified_at' => $this->email_verified_at?->toIso8601String(),
|
|
'organisations' => $this->whenLoaded('organisations', fn () =>
|
|
$this->organisations->map(fn ($org) => [
|
|
'id' => $org->id,
|
|
'name' => $org->name,
|
|
'slug' => $org->slug,
|
|
'role' => $org->pivot->role,
|
|
])
|
|
),
|
|
'app_roles' => $this->getRoleNames()->values()->all(),
|
|
'permissions' => $this->getAllPermissions()->pluck('name')->values()->all(),
|
|
'portal_events' => $this->whenLoaded('persons', fn () =>
|
|
$this->persons->map(fn (Person $person) => [
|
|
'event_id' => $person->event_id,
|
|
'event_name' => $person->event->name,
|
|
'event_slug' => $person->event->slug,
|
|
'organisation_name' => $person->event->organisation->name,
|
|
'person_id' => $person->id,
|
|
'person_status' => $person->status,
|
|
'start_date' => $person->event->start_date?->toDateString(),
|
|
'end_date' => $person->event->end_date?->toDateString(),
|
|
])
|
|
),
|
|
];
|
|
}
|
|
}
|