26 lines
1.1 KiB
PHP
26 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Mne;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/** Read-only comparison adapter. Does not hydrate a legacy model or grant authority. */
|
|
final class MneBusinessRepository
|
|
{
|
|
/** @return array<string, mixed>|null */
|
|
public function comparison(string $legacyId): ?array
|
|
{
|
|
$row = DB::table('mne.business_links as l')
|
|
->join('mne.existing_businesses as b', 'b.id', '=', 'l.canonical_business_id')
|
|
->join('mne.business_modalities as m', 'm.id', '=', 'b.modality_id')
|
|
->join('mne.workflow_states as s', 's.id', '=', 'b.status_id')
|
|
->join('mne.data_classifications as c', 'c.id', '=', 'b.confidentiality_id')
|
|
->where('l.legacy_business_id', $legacyId)->where('l.status', 'active')
|
|
->where('l.valid_from', '<=', now())->where(fn ($q) => $q->whereNull('l.valid_until')->orWhere('l.valid_until', '>', now()))
|
|
->whereNull('b.deleted_at')->first(['b.public_code as code', 'm.code as modality', 's.code as status',
|
|
'c.code as classification', 'b.version as version_no']);
|
|
|
|
return $row ? (array) $row : null;
|
|
}
|
|
}
|