You've already forked Atomcms-edit
81e99933e4
- DRY FurniEditorController: extract duplicate try/catch blocks into handleApiError(), formatItemData(), buildUpdateData(), buildInsertData(), castValue() methods - ProfileController: replace 45 lines of manual date formatting with Carbon's diffForHumans() - Replace custom Password rule (180 lines) with Laravel's built-in Password::min() rule - RadioController: extract RadioStreamService and RadioScheduleService, reducing from 608 to 323 lines - Add RadioSettings enum to replace magic strings throughout radio feature - Add CurrencyTypes::columnName() helper method - Add consistent return types (JsonResponse, View, RedirectResponse) to all controller methods
66 lines
1.7 KiB
PHP
Executable File
66 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum CurrencyTypes: int
|
|
{
|
|
case Credits = -1;
|
|
case Duckets = 0;
|
|
case Diamonds = 5;
|
|
case Points = 101;
|
|
|
|
/**
|
|
* @return array<int>
|
|
*/
|
|
public static function values(): array
|
|
{
|
|
return array_column(self::cases(), 'value');
|
|
}
|
|
|
|
public static function fromCurrencyName(string $currencyName): ?self
|
|
{
|
|
$currencyName = strtolower($currencyName);
|
|
|
|
return match ($currencyName) {
|
|
'credits' => self::Credits,
|
|
'duckets' => self::Duckets,
|
|
'diamonds' => self::Diamonds,
|
|
'points' => self::Points,
|
|
default => null,
|
|
};
|
|
}
|
|
|
|
public function columnName(): string
|
|
{
|
|
return match ($this) {
|
|
self::Credits => 'credits',
|
|
self::Duckets => 'duckets',
|
|
self::Diamonds => 'diamonds',
|
|
self::Points => 'points',
|
|
};
|
|
}
|
|
|
|
public function getImage(): string
|
|
{
|
|
return match ($this->value) {
|
|
CurrencyTypes::Credits->value => asset('assets/images/currencies/credits.gif'),
|
|
CurrencyTypes::Duckets->value => asset('assets/images/currencies/duckets.png'),
|
|
CurrencyTypes::Diamonds->value => asset('assets/images/currencies/diamonds.png'),
|
|
CurrencyTypes::Points->value => asset('assets/images/currencies/points.png'),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function toInput(): array
|
|
{
|
|
$allCurrencies = self::cases();
|
|
|
|
return array_combine(
|
|
array_column($allCurrencies, 'value'),
|
|
array_column($allCurrencies, 'name'),
|
|
);
|
|
}
|
|
}
|