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>
59 lines
2.3 KiB
PHP
59 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\Api\V1;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
final class PersonIdentityMatchResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'person' => [
|
|
'id' => $this->person->id,
|
|
'name' => $this->person->name,
|
|
'email' => $this->person->email,
|
|
'crowd_type' => $this->whenLoaded('person', fn () =>
|
|
$this->person->crowdType?->name
|
|
),
|
|
'event' => $this->whenLoaded('person', fn () => [
|
|
'id' => $this->person->event_id,
|
|
'name' => $this->person->event?->name,
|
|
]),
|
|
],
|
|
'matched_user' => [
|
|
'id' => $this->matchedUser->id,
|
|
'first_name' => $this->matchedUser->first_name,
|
|
'last_name' => $this->matchedUser->last_name,
|
|
'full_name' => $this->matchedUser->full_name,
|
|
'email' => $this->matchedUser->email,
|
|
'date_of_birth' => $this->matchedUser->date_of_birth?->toDateString(),
|
|
],
|
|
'matched_on' => $this->matched_on->value,
|
|
'matched_on_label' => $this->matched_on->label(),
|
|
'confidence' => $this->confidence->value,
|
|
'confidence_label' => $this->confidence->label(),
|
|
'status' => $this->status->value,
|
|
'status_label' => $this->status->label(),
|
|
'match_details' => $this->match_details,
|
|
'confirmed_by' => $this->when($this->confirmedBy, fn () => [
|
|
'id' => $this->confirmedBy->id,
|
|
'full_name' => $this->confirmedBy->full_name,
|
|
]),
|
|
'confirmed_at' => $this->confirmed_at?->toIso8601String(),
|
|
'dismissed_at' => $this->dismissed_at?->toIso8601String(),
|
|
'reverted_at' => $this->reverted_at?->toIso8601String(),
|
|
'resolved_by' => $this->when($this->resolvedBy, fn () => [
|
|
'id' => $this->resolvedBy->id,
|
|
'full_name' => $this->resolvedBy->full_name,
|
|
]),
|
|
'resolved_at' => $this->resolved_at?->toIso8601String(),
|
|
'created_at' => $this->created_at->toIso8601String(),
|
|
];
|
|
}
|
|
}
|