feat: person identity matching with detection, confirmation and audit trail
Implements enterprise-grade identity resolution (detect → suggest → confirm) for Person ↔ User linking. Matches are detected automatically on person creation and user account creation, then surfaced to organisers for explicit confirmation or dismissal. No silent auto-linking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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,
|
||||
'name' => $this->matchedUser->name,
|
||||
'email' => $this->matchedUser->email,
|
||||
],
|
||||
'matched_on' => $this->matched_on->value,
|
||||
'confidence' => $this->confidence->value,
|
||||
'status' => $this->status->value,
|
||||
'resolved_by' => $this->when($this->resolvedBy, fn () => [
|
||||
'id' => $this->resolvedBy->id,
|
||||
'name' => $this->resolvedBy->name,
|
||||
]),
|
||||
'resolved_at' => $this->resolved_at?->toISOString(),
|
||||
'created_at' => $this->created_at->toISOString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,23 @@ final class PersonResource extends JsonResource
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'crowd_type' => new CrowdTypeResource($this->whenLoaded('crowdType')),
|
||||
'company' => new CompanyResource($this->whenLoaded('company')),
|
||||
'pending_identity_match' => $this->when(
|
||||
$this->relationLoaded('pendingIdentityMatch') && $this->pendingIdentityMatch,
|
||||
function () {
|
||||
$match = $this->pendingIdentityMatch;
|
||||
|
||||
return [
|
||||
'match_id' => $match->id,
|
||||
'matched_user' => [
|
||||
'id' => $match->matchedUser->id,
|
||||
'name' => $match->matchedUser->name,
|
||||
'email' => $match->matchedUser->email,
|
||||
],
|
||||
'matched_on' => $match->matched_on->value,
|
||||
'confidence' => $match->confidence->value,
|
||||
];
|
||||
}
|
||||
),
|
||||
'tags' => $this->when(
|
||||
$this->user_id && $this->relationLoaded('user'),
|
||||
function () {
|
||||
|
||||
Reference in New Issue
Block a user