buckets/app/Enums/BucketAllocationTypeEnum.php

34 lines
819 B
PHP
Raw Normal View History

2025-12-31 01:33:44 +01:00
<?php
namespace App\Enums;
2025-12-31 02:34:30 +01:00
enum BucketAllocationTypeEnum: string
2025-12-31 01:33:44 +01:00
{
case FIXED_LIMIT = 'fixed_limit';
case PERCENTAGE = 'percentage';
case UNLIMITED = 'unlimited';
public function getLabel(): string
{
return match ($this) {
2025-12-31 01:33:44 +01:00
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', 'integer', 'min:0'],
self::PERCENTAGE => ['required', 'integer', 'min:1', 'max:10000'],
2025-12-31 01:33:44 +01:00
self::UNLIMITED => ['nullable'],
};
}
}