|null whmcs client id => local customer id */ private static ?array $map = null; public function resolve(int $whmcsClientId): ?int { self::$map ??= $this->build(); return self::$map[$whmcsClientId] ?? null; } private function build(): array { $uuidsByWhmcsId = DB::connection('whmcs')->table('tblclients')->pluck('uuid', 'id'); $customerIdsByUuid = DB::table('customers')->pluck('id', 'uuid'); $map = []; foreach ($uuidsByWhmcsId as $whmcsId => $uuid) { if (isset($customerIdsByUuid[$uuid])) { $map[$whmcsId] = $customerIdsByUuid[$uuid]; } } return $map; } }