Files
Investidor-V2/app/Services/Mne/IdentityResolver.php
T
nala 3dc7c5c649
tests / ci (push) Canceled after 0s
commit 30/9
2026-09-30 09:05:43 +02:00

21 lines
698 B
PHP

<?php
namespace App\Services\Mne;
use Illuminate\Support\Facades\DB;
final class IdentityResolver
{
public function resolve(int $userId): ?string
{
$id = DB::table('mne.identity_links as l')->join('mne.parties as p', 'p.id', '=', 'l.party_id')
->join('public.users as u', 'u.id', '=', 'l.user_id')
->where('l.user_id', $userId)->where('l.status', 'active')->where('p.party_type', 'person')
->whereNull('p.deleted_at')->where('l.valid_from', '<=', now())
->where(fn ($q) => $q->whereNull('l.valid_until')->orWhere('l.valid_until', '>', now()))
->value('l.party_id');
return is_string($id) ? $id : null;
}
}