update email template
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Integrations\Whmcs\Support;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/** Resolves a WHMCS `tblproducts.id` to the local `products.id` via `legacy_id`. */
|
||||
class ProductIdResolver
|
||||
{
|
||||
/** @var array<int, int>|null */
|
||||
private static ?array $map = null;
|
||||
|
||||
public function resolve(int $legacyProductId): ?int
|
||||
{
|
||||
self::$map ??= DB::table('products')->whereNotNull('legacy_id')->pluck('id', 'legacy_id')->all();
|
||||
|
||||
return self::$map[$legacyProductId] ?? null;
|
||||
}
|
||||
|
||||
public function categoryTypeOf(int $localProductId): ?string
|
||||
{
|
||||
return DB::table('products')
|
||||
->join('product_categories', 'product_categories.id', '=', 'products.product_categories_id')
|
||||
->where('products.id', $localProductId)
|
||||
->value('product_categories.type');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user