Merge pull request #4085 from lucasmichot/feat/match

Use match when possible.
This commit is contained in:
🏔️ Peak
2024-10-31 16:24:50 +01:00
committed by GitHub
2 changed files with 28 additions and 55 deletions

View File

@@ -62,32 +62,21 @@ class Danger extends Component
return; return;
} }
switch ($this->resource->type()) { $this->resourceName = match ($this->resource->type()) {
case 'application': 'application' => $this->resource->name ?? 'Application',
$this->resourceName = $this->resource->name ?? 'Application'; 'standalone-postgresql',
break; 'standalone-redis',
case 'standalone-postgresql': 'standalone-mongodb',
case 'standalone-redis': 'standalone-mysql',
case 'standalone-mongodb': 'standalone-mariadb',
case 'standalone-mysql': 'standalone-keydb',
case 'standalone-mariadb': 'standalone-dragonfly',
case 'standalone-keydb': 'standalone-clickhouse' => $this->resource->name ?? 'Database',
case 'standalone-dragonfly': 'service' => $this->resource->name ?? 'Service',
case 'standalone-clickhouse': 'service-application' => $this->resource->name ?? 'Service Application',
$this->resourceName = $this->resource->name ?? 'Database'; 'service-database' => $this->resource->name ?? 'Service Database',
break; default => 'Unknown Resource',
case 'service': };
$this->resourceName = $this->resource->name ?? 'Service';
break;
case 'service-application':
$this->resourceName = $this->resource->name ?? 'Service Application';
break;
case 'service-database':
$this->resourceName = $this->resource->name ?? 'Service Database';
break;
default:
$this->resourceName = 'Unknown Resource';
}
} }
public function delete($password) public function delete($password)

View File

@@ -22,35 +22,19 @@ class PricingPlans extends Component
{ {
$team = currentTeam(); $team = currentTeam();
Stripe::setApiKey(config('subscription.stripe_api_key')); Stripe::setApiKey(config('subscription.stripe_api_key'));
switch ($type) {
case 'basic-monthly': $priceId = match ($type) {
$priceId = config('subscription.stripe_price_id_basic_monthly'); 'basic-monthly' => config('subscription.stripe_price_id_basic_monthly'),
break; 'basic-yearly' => config('subscription.stripe_price_id_basic_yearly'),
case 'basic-yearly': 'pro-monthly' => config('subscription.stripe_price_id_pro_monthly'),
$priceId = config('subscription.stripe_price_id_basic_yearly'); 'pro-yearly' => config('subscription.stripe_price_id_pro_yearly'),
break; 'ultimate-monthly' => config('subscription.stripe_price_id_ultimate_monthly'),
case 'pro-monthly': 'ultimate-yearly' => config('subscription.stripe_price_id_ultimate_yearly'),
$priceId = config('subscription.stripe_price_id_pro_monthly'); 'dynamic-monthly' => config('subscription.stripe_price_id_dynamic_monthly'),
break; 'dynamic-yearly' => config('subscription.stripe_price_id_dynamic_yearly'),
case 'pro-yearly': default => config('subscription.stripe_price_id_basic_monthly'),
$priceId = config('subscription.stripe_price_id_pro_yearly'); };
break;
case 'ultimate-monthly':
$priceId = config('subscription.stripe_price_id_ultimate_monthly');
break;
case 'ultimate-yearly':
$priceId = config('subscription.stripe_price_id_ultimate_yearly');
break;
case 'dynamic-monthly':
$priceId = config('subscription.stripe_price_id_dynamic_monthly');
break;
case 'dynamic-yearly':
$priceId = config('subscription.stripe_price_id_dynamic_yearly');
break;
default:
$priceId = config('subscription.stripe_price_id_basic_monthly');
break;
}
if (! $priceId) { if (! $priceId) {
$this->dispatch('error', 'Price ID not found! Please contact the administrator.'); $this->dispatch('error', 'Price ID not found! Please contact the administrator.');