Files
crewli/api/app/Http/Resources/Api/V1/PersonIdentityMatchResource.php
bert.hausmans 4b182b449a 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>
2026-04-10 12:50:25 +02:00

45 lines
1.5 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,
'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(),
];
}
}