refactor(pricing): optimize plan provider retrieval with active filtering

- Replace getAllowedProviders() method with direct database query
  - Add filtering for enabled plan providers and active payment providers
  - Include sort ordering for consistent provider display
  - Improve performance by using direct database access instead of model method
This commit is contained in:
idevakk
2025-12-02 11:16:20 -08:00
parent 6056740a3f
commit 3cd6c0f7cc

View File

@@ -157,7 +157,17 @@ class Pricing extends Component
{ {
$plan = $this->plans->firstWhere('id', $planId); $plan = $this->plans->firstWhere('id', $planId);
return $plan ? $plan->getAllowedProviders() : []; if (! $plan) {
return [];
}
return $plan->planProviders()
->enabled()
->join('payment_providers', 'plan_providers.provider', '=', 'payment_providers.name')
->where('payment_providers.is_active', true)
->orderBy('plan_providers.sort_order')
->pluck('plan_providers.provider')
->toArray();
} }
/** /**