|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'); } }