20 lines
534 B
PHP
20 lines
534 B
PHP
<?php
|
|
|
|
namespace App\Integrations\Whmcs\Support;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/** Resolves a WHMCS `tblhosting.id` to the local `order_items.id` via `legacy_id` (1:1, same source row). */
|
|
class OrderItemIdResolver
|
|
{
|
|
/** @var array<int, int>|null */
|
|
private static ?array $map = null;
|
|
|
|
public function resolve(int $legacyHostingId): ?int
|
|
{
|
|
self::$map ??= DB::table('order_items')->whereNotNull('legacy_id')->pluck('id', 'legacy_id')->all();
|
|
|
|
return self::$map[$legacyHostingId] ?? null;
|
|
}
|
|
}
|