5 - Clean up dead formatting code and tighten buffer validation
This commit is contained in:
parent
8f6de4aace
commit
66fb866f42
3 changed files with 2 additions and 18 deletions
|
|
@ -31,12 +31,4 @@ public function getAllocationValueRules(): array
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatValue(?float $value): string
|
|
||||||
{
|
|
||||||
return match ($this) {
|
|
||||||
self::FIXED_LIMIT => '$'.number_format($value ?? 0, 2),
|
|
||||||
self::PERCENTAGE => number_format($value ?? 0, 2).'%',
|
|
||||||
self::UNLIMITED => 'All remaining',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public function store(Request $request, Scenario $scenario): JsonResponse
|
||||||
'type' => 'required|in:'.implode(',', BucketTypeEnum::values()),
|
'type' => 'required|in:'.implode(',', BucketTypeEnum::values()),
|
||||||
'allocation_type' => 'required|in:'.implode(',', BucketAllocationTypeEnum::values()),
|
'allocation_type' => 'required|in:'.implode(',', BucketAllocationTypeEnum::values()),
|
||||||
'allocation_value' => 'nullable|numeric',
|
'allocation_value' => 'nullable|numeric',
|
||||||
'buffer_multiplier' => 'sometimes|nullable|numeric|min:0',
|
'buffer_multiplier' => 'sometimes|numeric|min:0',
|
||||||
'priority' => 'nullable|integer|min:1',
|
'priority' => 'nullable|integer|min:1',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ public function update(Request $request, Bucket $bucket): JsonResponse
|
||||||
'type' => 'required|in:'.implode(',', BucketTypeEnum::values()),
|
'type' => 'required|in:'.implode(',', BucketTypeEnum::values()),
|
||||||
'allocation_type' => 'required|in:'.implode(',', BucketAllocationTypeEnum::values()),
|
'allocation_type' => 'required|in:'.implode(',', BucketAllocationTypeEnum::values()),
|
||||||
'allocation_value' => 'nullable|numeric',
|
'allocation_value' => 'nullable|numeric',
|
||||||
'buffer_multiplier' => 'sometimes|nullable|numeric|min:0',
|
'buffer_multiplier' => 'sometimes|numeric|min:0',
|
||||||
'priority' => 'nullable|integer|min:1',
|
'priority' => 'nullable|integer|min:1',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,14 +149,6 @@ public function getAllocationTypeLabel(): string
|
||||||
return $this->allocation_type->getLabel();
|
return $this->allocation_type->getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get formatted allocation value for display.
|
|
||||||
*/
|
|
||||||
public function getFormattedAllocationValue(): string
|
|
||||||
{
|
|
||||||
return $this->allocation_type->formatValue($this->allocation_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get allocation value validation rules based on type.
|
* Get allocation value validation rules based on type.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue