update email template
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Integrations\Whmcs\Support;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/** Resolves a WHMCS registrar module slug (e.g. 'nhanhoa', 'PA') to the local `registrars.id`, matched case-insensitively on short_name. */
|
||||
class RegistrarIdResolver
|
||||
{
|
||||
/** @var array<string, int>|null lowercase short_name => registrar id */
|
||||
private static ?array $map = null;
|
||||
|
||||
public function resolve(string $whmcsRegistrar): ?int
|
||||
{
|
||||
$whmcsRegistrar = trim($whmcsRegistrar);
|
||||
if ($whmcsRegistrar === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
self::$map ??= DB::table('registrars')->pluck('id', 'short_name')
|
||||
->mapWithKeys(fn ($id, $shortName) => [mb_strtolower($shortName) => $id])
|
||||
->all();
|
||||
|
||||
return self::$map[mb_strtolower($whmcsRegistrar)] ?? null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user