Files
2026-09-09 16:56:22 +07:00

23 lines
632 B
PHP

<?php
namespace App\Integrations\Whmcs\Support;
use Illuminate\Support\Facades\DB;
/**
* Resolves a WHMCS `tblorders.id` to the matching local `orders.id` via `orders.legacy_id`.
* Orders must be synced (whmcs:sync-orders) before invoices for this to find anything.
*/
class OrderIdResolver
{
/** @var array<int, int>|null legacy order id => local order id */
private static ?array $map = null;
public function resolve(int $whmcsOrderId): ?int
{
self::$map ??= DB::table('orders')->whereNotNull('legacy_id')->pluck('id', 'legacy_id')->all();
return self::$map[$whmcsOrderId] ?? null;
}
}