34 lines
821 B
PHP
34 lines
821 B
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum BucketAllocationTypeEnum: string
|
|
{
|
|
case FIXED_LIMIT = 'fixed_limit';
|
|
case PERCENTAGE = 'percentage';
|
|
case UNLIMITED = 'unlimited';
|
|
|
|
public function getLabel(): string
|
|
{
|
|
return match ($this) {
|
|
self::FIXED_LIMIT => 'Fixed Limit',
|
|
self::PERCENTAGE => 'Percentage',
|
|
self::UNLIMITED => 'Unlimited',
|
|
};
|
|
}
|
|
|
|
public static function values(): array
|
|
{
|
|
return array_column(self::cases(), 'value');
|
|
}
|
|
|
|
public function getAllocationValueRules(): array
|
|
{
|
|
return match ($this) {
|
|
self::FIXED_LIMIT => ['required', 'numeric', 'min:0'],
|
|
self::PERCENTAGE => ['required', 'numeric', 'min:0.01', 'max:100'],
|
|
self::UNLIMITED => ['nullable'],
|
|
};
|
|
}
|
|
|
|
}
|