feat(admin): improve payments and server settings
This commit is contained in:
@@ -25,6 +25,31 @@ enum ProductBillingCycle: string
|
||||
};
|
||||
}
|
||||
|
||||
public function vietnameseLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ONE_TIME => 'Một lần',
|
||||
self::MONTHLY => 'Hàng tháng',
|
||||
self::QUARTERLY => '3 tháng',
|
||||
self::SEMI_ANNUALLY => '6 tháng',
|
||||
self::ANNUALLY => 'Hàng năm',
|
||||
self::BIENNIALLY => '2 năm',
|
||||
self::TRIENNIALLY => '3 năm',
|
||||
};
|
||||
}
|
||||
|
||||
public static function vietnameseLabelFor(?string $code): string
|
||||
{
|
||||
return self::tryFrom((string) $code)?->vietnameseLabel() ?? ($code ?: 'N/A');
|
||||
}
|
||||
|
||||
public static function vietnameseLabelForMonths(int $months): string
|
||||
{
|
||||
$cycle = collect(self::cases())->first(fn (self $case) => $case->months() === $months && $months > 0);
|
||||
|
||||
return $cycle?->vietnameseLabel() ?? $months . ' tháng';
|
||||
}
|
||||
|
||||
public function months(): int
|
||||
{
|
||||
return match ($this) {
|
||||
|
||||
Reference in New Issue
Block a user